Objective: To avoid garbled occurrences, keep the server, database, project, and front-end code consistent.
First, the project and the front-end code, set.
MyEclipse---> Right-click Project--->properties--->resource--->text file encoding-----> select UTF-8---->apply--- >ok
Second, tomcat6.x server encoding settings
D:\apache-tomcat-6.0.37\conf\server.xml,
[HTML]View plain copy
- <Connector port="8080" protocol="http/1.1 "
- connectiontimeout="20000"
- redirectport= "8443" uriencoding="UTF-8"/>
[HTML]View plain copy
- <Connector port="8009" protocol="ajp/1.3" redirectport="8443" uriencoding= "UTF-8"/>
The uriencoding= "UTF-8" in the back is what is added.
Third, the database MySQL5.5 settings;
① first open the service running--->cmd--->net stop mysql off MySQL
②c:\program Files (x86) \mysql\mysql Server 5.5\my.ini
Modify the following four fields
[HTML]View plain copy
- [Client]
- Port = 3306
- default-character-set=UTF8
[HTML]View plain copy
- [MySQL]
- default-character-set=UTF8
[HTML]View plain copy
- [Mysqld]
- character-set-server=UTF8
- Port = 3306
[HTML]View plain copy
- character-set-server=UTF8
Save.
③ Open Run--->cmd--->net start mysql on MySQL service
④ open MySQL command line interface, enter the password after entering
Execute show variables like ' character% '; the statement, which appears as follows, indicates that the setting was successful
Java Web Background Insert Database Chinese garbled problem solving