1:html页面设置编码 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

2:web.xml中设置编码

<mime-mapping>
<extension>htm</extension>
<mime-type>text/html;charset=UTF-8</mime-type>
</mime-mapping>
<mime-mapping>
<extension>html</extension>
<mime-type>text/html;charset=UTF-8</mime-type>
</mime-mapping>

3:Tomcat server.xml中设置编码

<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"/>

4:如果是IDE启动,设置启动参数 Debug configurations->tomat 8.0->argument

-Dfile.encoding=UTF8

如果是Tomcat服务形式启动,设置catalina.bat

set "JAVA_OPTS=%JAVA_OPTS% %JSSE_OPTS%" -Dfile.encoding=UTF8

5:将文件用记事本或者EditPlus打开,另存为UTF-8格式

以上5种基本可以告别tomcat中文乱码问题.