1. Set the character encoding of MyEclipse as follows: 1. go to Window -- Preferences -- General -- Workspace, and change the Default (GBK) option in the Text file encoding option to Other, set the value to UTF-8;
2. go to Window -- Preferences -- MyEclipse -- Files and Editors and change the character encoding in ASP and PHP, CSS, DTD, HTML, JSP, and XML to UTF-8;
3. If necessary, add the following code to all JSP page headers: <% request. setCharacterEncoding ("UTF-8"); %> to prevent garbled characters when page values are passed; 4. If a Servlet File is called, add the following two lines of code to the Servlet File: request. setCharacterEncoding ("UTF-8 ");
Response. setCharacterEncoding ("UTF-8 ");
2. Set the mysql character encoding and disable the mysql service. Otherwise, the result is changed to the draft for the first time, and duplicate garbled characters are displayed for the second time:
Modify the encoding method in my. init to gbk as follows (it must be gbk. If it is utf8, the database will not be able to insert Chinese data gb2312)
Content to be modified:
Default-character-set = gbk
3. Configuration File Modification Scheme:
Xml configuration file modification scheme:
<Property name = "connection. url"> jdbc: mysql: // localhost: 3306/yinhang? UseUnicode = true & amp; characterEncoding = gbk </property>
Modification Scheme of properties file:
# Hibernate. connection. url jdbc: mysql: // localhost: 3306/yinhang? UseUnicode = true & characterEncoding = gbk