get请求参数中文乱码的解决办法
在tomcat的server.xml里的Connector加个URIEncoding="UTF-8",把
<Connector connectionTimeout="50000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
改为
<Connector connectionTimeout="50000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8"/>
post请求参数中文乱码的解决办法(两种)
1.配置了字符集过滤器
<filter>
<description>XXX</description>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<description>XXX</description>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
2.请求参数前使用
request.setCharacterEncoding("UTF-8");
原文地址:https://www.cnblogs.com/lanqingyu/p/10442980.html
时间: 2024-10-20 16:54:57