Summary of garbled problems

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.