修改tomcat的配置文件 1)修改Tomcat的server.xml配置(config目录下) 先找到第一处添加URIEncoding=“UTF-8”
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/>
再找到第二处添加URIEncoding=“UTF-8”
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8"/>
2)修改catalina.bat配置(bin目录下)
找到"JAVA_OPTS=%JAVA_OPTS% %JSSE_OPTS%"换行添加 -Dfile.encoding=UTF8 -Dsun.jnu.encoding=UTF8if not "%JSSE_OPTS%" == "" goto gotJsseOpts set "JSSE_OPTS=-Djdk.tls.ephemeralDHKeySize=2048" :gotJsseOpts set "JAVA_OPTS=%JAVA_OPTS% %JSSE_OPTS%" -Dfile.encoding=UTF8 -Dsun.jnu.encoding=UTF8
3)修改tomcat的 web.xml配置
<servlet> <servlet-name>default</servlet-name> <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>fileEncoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>listings</param-name> <param-value>false</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>
2022.11.14 标签:JAVA,Tomcat,encoding,UTF8,eclipse,OPTS%,乱码,JSSE,OPTS From: https://www.cnblogs.com/breeze-zZ/p/17614593.html