springMVC中post、get中文乱码的解决方法
程序员文章站
2022-04-03 08:55:22
...
post乱码
在web.xml
配置文件中添加
<!--解决post请求中文乱码问题-->
<filter>
<filter-name>characterEncodingFilter</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>
get乱码
在tomcat的conf
文件下server.xml
中的<Connector>
标签中添加URIEncoding="UTF-8"
<Connector URIEncoding="UTF-8 port="8070" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
推荐阅读