structs 2.2中文乱码

我用的tomcat服务器,用dom4j解析的xml,发现structs2中即使加了<constant name="struts.i18n.encoding" value="utf-8"></constant>还是有中文乱码问题,这个不是1.6中的bug吗,怎么到了2.2还是有问题,还是我其他配置没弄对,这个就不得而知了,只能等到高手看到这篇文章后,弱弱的给我解决一下了。

下面说一下我的解决方法吧,由于比较懒,没写什么过滤器,项目中也没用spring,所以只好在dom4j解析的代码中返回字符串的时候加上:

String result = new String(doc.asXML().getBytes(),"ISO-8859-1");

return result;

猜你喜欢

转载自magicbird.iteye.com/blog/1025458