MySQL Default character encoding is Latin1, and Java corresponds to the ISO-8859-1. To correctly display our Chinese characters, you only need to change the character encoding method of MySQL from Latin1 to Chinese and change it to "GBK" or "gb2312 ", there are two ways to modify:
one is to reconfigure mysql. In its Configuration Wizard, one is to enable you to select character encoding. You can choose Custom options, then define it as "GBK" or "gb2312".
the other is to directly modify "My. INI file. Find the file in the MySQL installation directory and open it in Notepad. Find the following two sentences:
[My SQL]
default-character-set = Latin1
[My sqld]
......
......
default-character-set = Latin1
replace Latin1 with "GBK". Be sure to use lower-case letters. I heard that uppercase letters are not recognized.
After the MySQL database is modified, we only need to set the character set of the JSP page to GBK.
<% @ Page Language = "Java" contenttype = "text/html; charset = GBK"
Pageencoding = "GBK" %>
If a filter exists, you should change the encoding format in the filter to GBK.
No other modifications are required. The garbled problem in the database should be solved.