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.