SSM-SpringMVC-19:SpringMVC中请求和响应的乱码解决
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥-------------
配置一道拦截器即可解决乱码
配置方式如下:
在web.xml中:
<!--过滤器处理乱码--> <filter> <filter-name>CharacterEncoding</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>CharacterEncoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>