Mysql Chinese display problems

Source: Internet
Author: User

I have been working on mysql Chinese display problems for the last two days. It is quite depressing.

Test Platform: struts1.2 + myeclipse5.5 + hibernate + mysql5.1

The test results today are:

When the default Character Set of mysql is set as follows, (show variables ;)

Character_set_client | utf8
Character_set_connection | utf8
Character_set_database | utf8
Character_set_filesystem | binary
Character_set_results | utf8
Character_set_server | utf8
Character_set_system | utf8
Character_sets_dir | C :\mysql-5.1.6 \ share \ charsets \

 

My. iniThe file content is as follows:

[Mysqld]
Basedir = C:/mysql-5.1.6
Datadir = C:/mysql-5.1.6/data
Default-character-set = utf8

[Client]

Port = 3306

[Mysql]

Default-character-set = utf8

[WinMYSQLadmin]
Server = C:/mysql-5.1.6/bin/mysqld-nt.exe

 

Or

Set the content of the my. ini file:

[Mysqld]
Basedir = C:/mysql-5.1.6
Datadir = C:/mysql-5.1.6/data
Default-character-set = gbk

[Client]

Port = 3306

[Mysql]

Default-character-set = gbk

[WinMYSQLadmin]
Server = C:/mysql-5.1.6/bin/mysqld-nt.exe

 

Hibernate urlThe configuration is as follows:

<Property name = "connection. url">
Jdbc: mysql: // localhost: 3306/test
</Property>

 

Form request: get or postCan print normal Chinese characters in the background,

ThenSet the jsp page character set to gbkThe inserted Chinese Characters in mysql are displayed normally, and the inserted Chinese characters can also be displayed on the jsp page.

The problem is finally solved!

 

Note:Implement the RequestProcessor interface in struts.

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.