提供参考,自己也不是很懂
1.当jsp文件是method="post"时
可以在web.xml文件中配置
<filter> <filter-name>encoding</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <!-- 设置编码参是UTF8 --> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
2.当Jsp文件中Method="get"时
可以修改Servers中Tomcat的server.xml文件中第66行
原: <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
后: <Connector URIEncoding="utf-8" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
3.当是响应乱码时(前面时提交问题)
response.setCharacterEncoding("utf-8");