首先把你的页面设置成这个字符集:
Window--Preferences--输入jsp,搜索--点击jsp--在相应的字符集设置上设置成自己想要的编码集。
如果这样还是不行的话,说明你数据库字符集设置有问题,这样设置:
首先把MySQL的服务停掉 在运行窗口输入:net stop mysql
把服务器和客户端的字符集改成自己想用的字符集:GB2312
具体 *** 作为:打开mysql安装目录下的myini.tet
一、打开mysql控制台,输入命令show variables like 'character%'显示如下:
+--------------------------+-------------------------------------------+
| Variable_name | Value |
+--------------------------+-------------------------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_results | latin1 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | C:\MySQL\MySQL Server 5.0\share\charsets\ |
+--------------------------+-------------------------------------------+
二、修改my.ini文件
[client]
default-character-set=utf8
[mysqld]
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
三、重启后使用第一步的命令查看,如下:
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
还有character_set_database和character_set_server的默认字符集还是latin1。
四、输入命令:set names utf8
重启后,使用第一步命令查看:
+--------------------------+------------------------------------------------+
| Variable_name | Value |
+--------------------------+------------------------------------------------+
| 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:\wamp64\bin\mysql\mysql5.7.9\share\charsets\ |
+--------------------------+------------------------------------------------+
除了character_set_filesystem是binary外,其他都是utf8了,
这样在web端也设置成utf8编码就可以正常输入数据库了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)