1 Handling garbled mode:
1 when connecting to the database
Jdbc.properties:jdbc:mysql://localhost:3306/myproject?useunicode=true&characterencoding=utf8
2 Modifying the MySQL configuration file my.ini/my.cnf Default-character-set=utf8
3 Modify the configuration file in Tomcat Server.xml instead
<connector port= "8080" protocol= "http/1.1"
connectiontimeout= "20000"
Redirectport= "8443" uriencoding= "UTF-8"/>
4 Configuring the Spring filter in Web. xml
<filter>
<filter-name>char</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>char</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
5 setting up the MySQL character set
Show variables like ' character_set_% ';
The displayed character_set_** are all set to UTF8, that is: Set character_set_serve= ' UTF8 '
Show variables like '%collation% ';
Set the display to be as follows: Set collation_server= ' Utf8_general_ci '
6. The Chinese characters in the HTTP (POST) request when the value is taken
In the servlet page, add
Request.setcharacterencoding ("Utf-8");
user_name = Request.getparameter ("user_name") = = null? "": Java.net.URLDecoder.decode (Request.getparameter ("user_name"), "UTF-8");
7. Front desk back????
Background assignment: errormessage = Urlencoder.encode ("No periodic data information in Redis", "UTF-8"). Replace ("+", "%20");
Front desk value: decodeURIComponent (errormessage)
Java Chinese garbled problem solving