m
spring-mvc提交表单乱码处理
比如我们在Jsp文件中设置是UTF-8编码:
<%@ page language="java" contentType="text/html; UTF-8" pageEncoding="utf-8" %>
当我们使用表单提交数据的时候中文显示的是乱码,这个时候我们需要设置spring过滤器:
<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>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>