笑饭饭

struts2乱码

在spring.jar包的org.springframework.web.filter包下有个CharacterEncodingFilter.java

把spring.jar放进工程的lib里,然后在web.xml文件中<servlet>元素前加以下代码


注意要把CharacterEncodingFilter放在其他过滤器之前声明。

<!-- 著名 Character Encoding filter -->
    <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>
    <!-- 其他某过滤器 -->
    <filter>
        <filter-name>eXtremeExport</filter-name>
        <filter-class>
            org.extremecomponents.table.filter.ExportFilter
        </filter-class>
    </filter>
    <filter-mapping>
        <filter-name>eXtremeExport</filter-name>
        <url-pattern>*.do</url-pattern>
    </filter-mapping>

posted on 2016-01-28 23:02  笑饭饭  阅读(107)  评论(0编辑  收藏  举报