Eclipse queries MySql and adds Chinese garbled characters

Source: Internet
Author: User

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


Related Article

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.