在struts.xml中设置
<struts>
<constant name="struts.i18n.encoding" value="utf-8"></constant>
</struts>
后端的数据库如果和你的系统编码有关,比如GBK编码,这时可以用Spring字符编码拦截器,在业务层把相关编码转成GBK
在web.xml中设置
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>gbk</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/</url-pattern>
</filter-mapping>
</filter>