在struts2里面配置一个常量
[html] view plaincopy
<!--指定Web应用的默认编码集,相当于调用HttpServletRequest的setCharacterEncoding方法-->
<constant name="struts.i18n.encoding" value="UTF-8"/>
或者是用spring 的filter(配置在web.xml中的struts2的filter的前面)
[html] view plaincopy
<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>
评论