标签:nec 字符集 gen filter port cee ram 编码格式 字符
spring MVC中默认的编码格式为“ISO-8859-1”,页面一般数据格式设置为UTF-8,所以导致了乱码
method=POST时
在web.xml中配置Spring字符过滤器,添加:
<!-- Spring字符集过滤器 --> <filter> <filter-name>SpringEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>SpringEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
method=GET时
在tomcat的server.xml添加URIEncoding=“utf-8”
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> 变更为: <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="utf-8"/>
标签:nec 字符集 gen filter port cee ram 编码格式 字符
原文地址:https://www.cnblogs.com/-217/p/13197312.html