您的位置:程序门 -> java -> j2ee / ejb / jms



struts+spring+hibernate - myeclipse+tomcat+postgres中文乱码问题,急!


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


struts+spring+hibernate - myeclipse+tomcat+postgres中文乱码问题,急![已结贴,结贴人:kingxin130]
发表于:2007-06-13 14:04:31 楼主
一个古老的问题,没想到还会跳出来困扰我一下

我的程序里:
1、jsp设置如下:
<%@   page   contenttype= "text/html;   charset=utf-8 "%>
...

2、myeclipse-> window-> preferences-> workspace-> text   file   encoding:
utf-8

3、web.xml:
<filter>
<filter-name> encoding </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>
</filter>

4、postgres数据库编码也为utf8

发现存到数据库里的总是乱码,去掉web.xml里的配置也是一样;也尝试过在tomcat的server.xml里增加uriencoding配置项,也不行。

我的理解是:浏览器默认的编码格式为iso-8859,所以从页面传到后台的中文变成乱码。

网上看到很多人建议:自己写filter转化编码,我总觉得struts或者spring已经考虑到了这些明显的编码问题,应该能够通过配置来实现编码转换!请大家帮忙!
发表于:2007-06-13 17:55:281楼 得分:0
关注
发表于:2007-06-14 16:14:262楼 得分:0
帮帮忙啊
发表于:2007-06-14 16:59:093楼 得分:50
你把页面换成iso-8859-1试试。把数据从数据库里取出来的时候转换一下。不行就换成gb2312。然后在页面显示的时候转换一下
发表于:2007-06-14 17:08:264楼 得分:0
up


快速检索

最新资讯
热门点击