2014-10-10 Record:
Garbled problem is in October when the reverse telecommuting, when the database was deposited, and later found out that the reason is the MySQL installation when the setup code is incorrect, reinstall MySQL solution.
First debug diagnosis is the foreground of the background garbled problem, or deposit into the database when the problem occurs.
1 Project just created, remember to change GBK code to U8
2 foreground background, Web. XML configures the filter for the spring framework, or the servlet sets the encoding
Request.setcharacterencoding ("Utf-8");
Response.setcharacterencoding ("Utf-8");
Response.setcontenttype ("Text/html;charset=utf-8");
<filter>
<filter-name>spring character encoding Filter</filter-name >
<filter-class>org.springframework.web.filter.CharacterEncodingFilter< /filter-class>
<init-param>
<param-name>encoding</param-name>
< param-value>gbk</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>spring character encoding filter </filter-name>
<url-pattern>/*</url-pattern>
</ Filter-mapping>
3 Setting the encoding when the database is created
SET character_set_client = UTF8;
SET character_set_results = UTF8;
SET character_set_connection = UTF8;
If the SQL statement add is intact, the Java code is added is garbled, it is possible that the project code and database encoding inconsistency caused by
4 Server OS default encoding problem, tomcat encoding is iso8859
Apache-tomcat-6.0.20\conf\server.xml
<connector port= "8080" protocol= "http/1.1"
connectiontimeout= "20000"
Redirectport= "8443" urlencoding= "UTF-8" usebodyencodingforuri= "true"/>
urlencoding= "UTF-8" usebodyencodingforuri= "true"
Both of them.
Summary of garbled problems