struts2中文乱码问题,谁来解释下struts2处理字符编码的原理?

为什么当在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>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
  <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>



<constant name="struts.i18n.encoding" value="GBK"/>

你可能感兴趣的:(java,xml,Web)