PowerShell重命名文件名


Get-ChildItem -Path "G:\doc\目录" | ForEach-Object {
$extension = $_.Extension
$oldName = $_.Name
$newName = $oldName -replace "-","_"
Rename-Item -Path $_.FullName -NewName $newName
}

 


Get-ChildItem -Path "G:\doc\目录" | ForEach-Object {
$extension = $_.Extension
$oldName = $_.Name
$newName = $oldName.SubString(0,3)+"_"+$oldName.SubString(3,$oldName.length-3)
Rename-Item -Path $_.FullName -NewName $newName
}

keytool生成密钥


keytool -genkeypair -alias allchainsserver -keyalg RSA -keystore d:\server.keystore
keytool -export -alias allchainsserver -keystore d:\server.keystore -file d:\server.crt
keytool -import -alias allchainsserver -file d:\server.crt -keystore d:\serverCrt.keystore

keytool -genkeypair -alias allchainsclient -keyalg RSA -keystore d:\client.keystore
keytool -export -alias allchainsclient -keystore d:\client.keystore -file d:\client.crt
keytool -import -alias allchainsclient -file d:\client.crt -keystore d:\clientCrt.keystore

keytool -importkeystore -srckeystore d:\client.keystore -destkeystore d:\client.p12 -srcalias allchainsclient -destalias allchainsclient -srcstoretype JKS -deststoretype PKCS12

 

解决Tomcat乱码的一种方案

有些项目直接将文本数据按字符/字节流输出导致的乱码

需要设置Tomcat的启动配置文件catalina.bat内插入如下内容

SET CATALINA_OPTS=-Dfile.encoding=utf8

解决Tomcat跨域问题

在web.xml内插入

<filter>
  <filter-name>CorsFilter</filter-name>
  <filter-class>
    org.apache.catalina.filters.CorsFilter
  </filter-class>
</filter>
<filter-mapping>
  <filter-name>CorsFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>