http://www.javashuo.com/article/p-vskxndiy-ez.htmlhtml
概述:web
Tomcat默认是 ISO编码,不支持中文。尝试过本身写 Filter,在web.xml中将本身写的FIlter放在最前面(不然不会执行Filter中的doFilter方法),甚至也在tomcat配置文件 server.xml中 的 Connector也添加了 URIEncoding="utf-8",以及在 eclipse中的properties也设置了 一样的编码方式,以后 经过在 struts.xml 中添加 apache
1 <constant name="struts.i18n.encoding" value="utf-8"></constant>
也仍是乱码。tomcat
最后,在 web.xml 中 的struts的filter添加(蓝色部分) eclipse
<filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class> <init-param> <param-name>struts.i18n.encoding</param-name> <param-value>utf-8</param-value> </init-param> </filter>
解决了问题。 我猜测,应该跟struts本身指定了编码有关。ide