Solution to Chinese garbled characters in JSP interaction with databases

Source: Internet
Author: User

At the beginning of the jsp file, it is best to add the following code. Now, the general IDE will automatically set the storage type to UTF-8. If you use Notepad for development, you need to select UTF-8 in the saved format.

% @ Page pageEncoding = "UTF-8" %

If there are still garbled characters, check whether the character set is set in HTML. If not, add:

<Meta http-equiv = Content-Type content = "text/html; charset = UTF-8"/>

Refresh the page after saving the file. If garbled characters still exist, the database garbled characters will not be more than 10.

Take Mysql as an example. During installation, we generally select the character set type as UTF-8. However, in Windows-based development environments, Mysql often does not support the UTF-8 format and needs to modify the encoding type.

Stop running Mysql, open the installation directory of Mysql, open the my. ini configuration file, and change UTF-8 to GBK at lines 57 and 81. default-character-set = GBK

Redeploy the project to solve the garbled problem.

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: 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.