Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java EE 综合讨论区 » Hibernate  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 SPRING+HIBERNATE+STRUTS写入数据库有乱码怎么处理
奶油





发贴: 71
积分: 0
于 2006-10-12 14:40 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的数据库(MYSQL5)的字符集是通过ENGINE=InnoDB DEFAULT CHARSET=utf8;设置成“UTF8”的
web里也是
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
设置了的
applicationContext.xml里也是
jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8
但写入数据库后还是“???”
在ACTION程序里加了
try {
request.setCharacterEncoding("UTF-8");
}
catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}

也不管用
还有什么地方没有设置的,谢谢



作者 Re:SPRING+HIBERNATE+STRUTS写入数据库有乱码怎么处理 [Re:奶油]
JAVA生





发贴: 44
积分: 0
于 2006-10-13 16:15 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
在Jsp里加一下转码试试



作者 Re:SPRING+HIBERNATE+STRUTS写入数据库有乱码怎么处理 [Re:奶油]
feiling





发贴: 26
积分: 0
于 2006-10-15 19:16 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
在获得字符串时作一个转换:
string = new String(string.getBytes("8859_1"),"gb2312");



作者 Re:SPRING+HIBERNATE+STRUTS写入数据库有乱码怎么处理 [Re:奶油]
lixj0571





发贴: 84
积分: 2
于 2006-10-28 21:42 user profilesend a private message to usersend email to lixj0571search all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
请确认你在写数据库之前,是否为乱码
如果是,说明是web层问题
如果不是,则说明是驱动程序及数据库设置的问题



作者 Re:SPRING+HIBERNATE+STRUTS写入数据库有乱码怎么处理 [Re:奶油]
ltshark





发贴: 4
积分: 0
于 2006-10-31 01:53 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
可能是命令行的问题吧?在执行命令前:set names "gbk";



flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923