Two types of problems encountered by the Java platform:
1. Source code Chinese garbled problem:
A.java file, Chinese garbled, configure the IDE's preference encoding format, there is always a suitable for you.
B.html (JSP 、.... ) file, Chinese garbled, add and set the HTML contenttype, CharSet can be. <%@ page contenttype= "TEXT/HTML;CHARSET=GBK"%>
2. Input Chinese garbled problem in the application:
A.selvert filter to handle Chinese garbled problem:
Modify the configuration parameters in Web. xml:
<filter> <!--Note This is filter, do not configure it as servlet-->
<filter-name>CharactorFilter</filter-name> <!--filter Name--
<filter-class>cn.com.Filter.CharactorFilter</filter-class> <!--filter's full class name--
<init-param> <!--initialization Parameters--
<param-name>encoding</param-name> <!--parameter name---
<param-value>utf-8</param-value><!--parameter Values--
</init-param>
</filter>
<filter-mapping> <!--filter Map--
<filter-name>CharactorFilter</filter-name><!--Filter Name--
<url-pattern>/*</url-pattern><!--URL mapping to handle all pages garbled---
</filter-mapping>
B.tomcat support for Chinese configuration issues: Change the Tomcat installation directory under Conf\server.xml, specify the browser's encoding format as "Simplified Chinese":
<connector port= "8080" maxthreads= "75" minsparethreads= "maxsparethreads="
Enablelookups= "false" redirectport= "8443" acceptcount= "100"
connectiontimeout= "20000" disableuploadtimeout= "true" uriencoding= ' GBK ' />
Note: The Chinese parameter of the Spring MVC controller parsing The Get method is garbled: the Spring filter only filters the HTTP POST method, and the Get method is not processed, so the configuration filter is not valid anyway. Therefore, you can only go back to the first layer, that is, from the Web application container layer to the Tomcat layer configuration Server.xml connector urieconding= "UTF-8" attribute.
Java Chinese garbled problem