Spring, SPRINGMVC integrated Web XML configuration

Source: Internet
Author: User

<?XML version= "1.0" encoding= "UTF-8"?><Web-appXmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xmlns= "Http://java.sun.com/xml/ns/javaee"xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" ID= "webapp_id"version= "3.0">    <welcome-file-list>        <Welcome-file>index.jsp</Welcome-file>    </welcome-file-list>      <!--first, the context to load the required configuration file -    <Context-param>        <Param-name>Contextconfiglocation</Param-name>        <Param-value>Classpath:spring/spring-dao.xml, Classpath:spring/spring-service.xml</Param-value>    </Context-param>        <!--Second, character filter -    <Filter>        <Filter-name>Encodingfilter</Filter-name>        <Filter-class>Org.springframework.web.filter.CharacterEncodingFilter</Filter-class>        <async-supported>True</async-supported>        <Init-param>            <Param-name>Encoding</Param-name>            <Param-value>UTF-8</Param-value>        </Init-param>    </Filter>    <filter-mapping>        <Filter-name>Encodingfilter</Filter-name>        <Url-pattern>/*</Url-pattern>    </filter-mapping>        <!--third, spring's listener -    <!--3.1. Memory leak processing listener This listener must be placed in the first location in the spring related listener to handle the Introspector memory leak problem, and spring does not have this memory leak problem, but Q Uartz,struts may appear <listener> <listener-class>org.springframework.web.util.introspectorcleanuplistene R</listener-class> </listener> -    <!--3.2, the Web container initiates the triggering of the listener when the Web container starts, loading some of the configuration files specified by the Context-param tag -    <Listener>        <Listener-class>Org.springframework.web.context.ContextLoaderListener</Listener-class>    </Listener>        <!--3.3. HTTP request listener If you need to configure a request, session, Global-session-scoped bean, you need to configure the following listeners <listener> <listene r-class> Org.springframework.web.context.request.RequestContextListener </listener-class> &L T;/listener> -        <!--Iv. the dispatcherservlet of Spring-mvc -    <servlet>        <Servlet-name>Dispatcherservlet</Servlet-name>        <Servlet-class>Org.springframework.web.servlet.DispatcherServlet</Servlet-class>        <Init-param>          <Param-name>Contextconfiglocation</Param-name>          <Param-value>Classpath:spring/spring-mvc.xml</Param-value>        </Init-param>        <Load-on-startup>1</Load-on-startup>        <!--whether to use asynchronous processing (servlet3.0 new), can improve the concurrency capability -        <async-supported>True</async-supported>    </servlet>    <!-- Five, access to the static resources to Defaultservlet processing before the Dispatcherservlet mapping can not go through the spring Dispatcherservlet can improve performance <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.css</url-p        attern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.js</url-pattern> </servlet-mapping> <servlet-mapping> &LT;SERVL    Et-name>default</servlet-name> <url-pattern>*.jpg</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*. jpg</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</serv        let-name> <url-pattern>*.jpeg</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*. jpeg</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</ser        vlet-name> <url-pattern>*.png</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*. png</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</serv        let-name> <url-pattern>*.gif</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*. gif</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</serv        let-name> <url-pattern>*.ico</url-pattern> </servlet-mapping> <servlet-mapping>    <servlet-name>default</servlet-name>    <url-pattern>*.swf</url-pattern> </servlet-mapping> <servlet-mapping> <servlet    -name>default</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.zip</url-pa        ttern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name>     <url-pattern>*.ttf</url-pattern> </servlet-mapping> -    <servlet-mapping>        <Servlet-name>Dispatcherservlet</Servlet-name>        <Url-pattern>/</Url-pattern>    </servlet-mapping>        <!--vi. Druid Data source monitoring servlet Access ip:port/project name/druid can access to DRUID data source monitoring page <servlet> <servlet-name>druid Statview</servlet-name> <servlet-class>com.alibaba.druid.support.http.statviewservlet</ servlet-class> </servlet> <servlet-mapping> <servlet-name>druidstatview</servlet-name > <url-pattern>/druid/*</url-pattern> </servlet-mapping> -        <!--vii. Session Expiration Time configuration -    <Session-config>        <Session-timeout>15</Session-timeout>    </Session-config></Web-app>

Spring, SPRINGMVC integrated Web XML configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.