There are several workarounds:
1, ensure that the character encoding of the project and each JSP page character encoding consistent, if inconsistent may lead to Chinese garbled problem <%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
2, write the filter filter, in the filter method Dofilter
Request.setcharacterencoding ("UTF-8");
Response.setcontenttype ("Text/html;charset=utf-8");
Configure the following information in Web. XML to filter all requests
<filter>
<filter-name>characterFilter</filter-name>
<filter-class> Custom Filter Class full-qualified class name </filter-class>
</filter>
<filter-mapping>
<filter-name>characterFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
3. Adding JSP configuration information to Web. xml
<jsp-config>
<jsp-property-group>
<description> for config the Web application </description>
<display-name>JSPConfiguration</display-name>
<url-pattern>*.jsp</url-pattern>
<el-ignored>false</el-ignored>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
In the JSP
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
The above three methods can be implemented, the second option is recommended, for any request, JSP and servlet can solve the Chinese problem
Java Read database Chinese information, why in the JSP page garbled