如何解决springMVC中文乱码问题?
由于Filter组件会在servlet之前执行
在拦截器中设置编码 CharacterEncodingFilter(Spring-web提供)
在web.xml中配置Filter
<filter> <filter-name>myfilter</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>myfilter</filter-name> <url-pattern>*.do</url-pattern> <!-- <servlet-name>springmvc</servlet-name> --> </filter-mapping>
时间: 2024-10-12 12:37:29