SpringMVC配置解决中文乱码的过滤器

SpringMVC框架中有提供解决get、post请求中文乱码的类,只需要在web.xml文件中配置该过滤器即可。

<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>
<filter-mapping>
	<filter-name>CharacterEncodingFilter</filter-name>
	<url-pattern>/*</url-pattern>
</filter-mapping>

  

posted @ 2017-09-30 19:52  JaneBaby  阅读(2226)  评论(3编辑  收藏  举报