SPRINGMVC provides a characterencodingfilter filter to solve garbled problems
Characterencodingfilter Steps to use:
1. form data to be submitted by post
The JSP page is set up as follows:
<form method= "POST" >
......
</form>
2. Configuring the Characterencodingfilter filter in Web. xml
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncoding</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
3. Page encoding is consistent with the encoding specified in the filter
The JSP page is set up as follows:
<%@ page contenttype= "text/html; Charset=utf-8 "pageencoding=" Utf-8 "%>
Note: The filter is acting on the servlet side and is called first before calling the servlet-side code.
Solution garbled when using the SPRINGMVC framework----characterencodingfilter Filter