1-08.BOS项目-解决中文乱码问题

 使用自己封装的处理乱码过滤器类。

 

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">

    <!-- 1.加载spring配置文件-->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:beans.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>


    <!--2.配置字符编码的过滤器-->
    <filter>
        <filter-name>characterEncodingFilter</filter-name>
        <!--spring-web包提供的CharacterEncodingFilter只能解决POST的中文乱码问题-->
        <!--<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>-->
        <filter-class>com.exp.bos.web.filter.MyEncodingFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>characterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
















    <!-- 3.配置struts的拦截器-->
    <filter>
        <filter-name>strut2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>strut2</filter-name>
        <url-pattern>/*</url-pattern>
        <!--请求和转发都会被strut2拦截
            默认情况下,只有请求会被拦截
        -->
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>

</web-app>

 

posted @ 2019-05-23 23:28  expworld  阅读(404)  评论(0)    收藏  举报