日期:2014-05-17  浏览次数:20708 次

jsp乱码《急》
从jsp中输出out.println( "中文 ");能正常显示中文   但是从jsp把数据插入数据库   数据库中的中文会是乱码
在每一个jsp中都写了 <%@   page   language= "java "   import= "java.util.* "   pageEncoding= "GB2312 "contentType= "text/html;   charset=GB2312 "%>
<%request.setCharacterEncoding( "GB2312 ");%>
我是用   MySQL5.5   在MySQL   中输入命令:   show   variables   like   '%char% ';
显示的结果:
                                Variable_name                                                   Value
                                  character_set_client                                     gb2312
                                  character_set_connection                             gb2312
                                  character_set_database                                 gb2312
                                  character_set_results                                   gb2312
                                  character_set_server                                     gb2312
                                  character_set_system                                     utf8
                                  character_set_filesystem                             binary

在my.ini中也写了[mysql]

default-character-set=gb2312

如果在[mysqld]后面写上   default-character-set=   gb2312   启动mysql就会报错

求各位高手快快解决。。万分感激!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1

------解决方案--------------------
为撒都是gb2312 ,用utf-8吧
------解决方案--------------------
建议卸载MySQL后,重新安装,安装时选择gb2312就可以了
------解决方案--------------------
换一种编码方式试试
------解决方案--------------------
都改成gbk就行了
------解决方案--------------------
首先确认安装mysql的时候选择了 gb2312,如果没有就卸掉重装mysql
------解决方案--------------------
你可以用oracle,oracle比较少出现编码问题。如果你真的非要用mysql的话,
连接mysql时候设置url为jdbc:mysql://127.0.0.1:3306/hibernatetest?useUnicode=true&characterEncoding=utf8