tomcat乱码html
时间: 2023-11-25 08:39:34 浏览: 69
设置tomcat的编码问题,主要是配置tomcat的server.xml和web.xml文件。在server.xml文件中,需要在Connector标签中添加URIEncoding="UTF-8",即:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8"/>
同时,在catalina.bat文件中,需要添加如下代码:
set "JAVA_OPTS=%JAVA_OPTS% %JSSE_OPTS%" -Dfile.encoding=UTF8 -Dsun.jnu.encoding=UTF8
此外,还需要在web.xml文件中,找到<servlet>标签,添加如下配置:
<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>
阅读全文