spring mvc get请求中文乱码问题

使用Spring MVC进行get请求时发现get请求带上中文参数,后台收到的是乱码,即使加了encoding filter也没用。

原因是,encoding filter 是针对post请求的,tomcat对get请求的处理方式不一样,需要修改tomcat 的server.xml配置文件

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

即加上  URIEncoding="UTF-8",重启tomcat后生效。这里有一点要注意,有些同学使用的是eclipse自带的tomcat,注意别改错了

另附上一篇文章,关于javaweb中发生编码与解码的讲解

http://www.jb51.net/article/80181.htm

原文地址:https://www.cnblogs.com/L-King/p/6917603.html