<filter> <filter-name>CharacterFilter</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> </filter> <filter-mapping> <filter-name>CharacterFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
设置request编码为utf-8
还可以在<filter>节点中添加
<init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param>
表示是否同时设置response编码