| 发表于: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已经考虑到了这些明显的编码问题,应该能够通过配置来实现编码转换!请大家帮忙! |
|
|
|
|