web.xml文件的配置

    技术2022-05-19  17

    <?xml version="1.0" encoding="UTF-8"?>

    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 

    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <welcome-file-list>

    <welcome-file>index.jsp</welcome-file>

    </welcome-file-list>

    <!-- 配置一个filter,用来处理中文乱码... -->

    <!-- 

    还可以在,struts.xml 中配置   <constant name="i18n.encoding" value="GBk"></constant> 

    它在2.1.6中是一个bug(不可以用!), 但是在2.1.8 的时候已经修正这个bug了(可以用!)

         -->

    <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,用来处理struts2的一个控制器... -->

    <filter>

    <filter-name>struts2</filter-name>

    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>

    </filter>

    <filter-mapping>

    <filter-name>struts2</filter-name>

    <url-pattern>/*</url-pattern>

    </filter-mapping>

    <!-- 配一个读取  applicationContext.xml 的一个插件-->

    <context-param>

    <param-name>contextConfigLocation</param-name>

    <param-value>classpath*:applicationContext.xml</param-value>

    </context-param>

     

    <listener>

    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

    </listener>

     

    </web-app>


    最新回复(0)