POST 请求
在web.xml中加上增加过滤器
1 <filter> 2 <filter-name>encodingFilter</filter-name> 3 <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> 4 <init-param> 5 <param-name>encoding</param-name> 6 <param-value>UTF-8</param-value> 7 </init-param> 8 <init-param> 9 <param-name>forceEncoding</param-name> 10 <param-value>true</param-value> 11 </init-param> 12 </filter> 13 <filter-mapping> 14 <filter-name>encodingFilter</filter-name> 15 <url-pattern>/*</url-pattern> 16 </filter-mapping>
GET 请求
修改 Tomcat根目录的 conf/server.xml文件,找<Connector port="8080" />,在里面加<Connector port="8080" uRIEncoding="utf-8" />