Spring MVC web.xml file analysis description
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" 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. Provide a name that GUI tools may use to label this particular web application --> <display-name>CESmart</display-name> <!-- //1. Used to declare the context initialization parameters within the application scope (the entire WEB project). --> <!-- //2.param-name, is key --> <!-- //3.param-value,为value --> <context-param> <param-name>WebApp</param-name> <param-value>com.proserver</param-value> </context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/configs/spring/applicationContext*.xml</param-value> </context-param> <!-- //1. Initialize the spring environment, use contextConfigLocation in context-param --> <!-- //2. The web container uses the instance of ContextLoaderListener to complete the initialization of SpringMVC, which is to establish a working environment (context) --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- //1. The servlet specified by the Context of the container (Tomcat) --> <!-- //2. servlet initialization and DispatcherServlet establish related mapping relationship --> <servlet> <servlet-name>SpringMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <!-- //1. Parameters used when DispatcherServlet runs, --> <!-- //2.DispatcherServlet needs to scan those names to find the controller, and establish a mapping table relationship --> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/configs/spring/mvc-demo-servlet.xml,/WEB-INF/configs/spring/applicationContext*.xml </param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- //1. The URL of the servlet specified by the Context of the container (Tomcat) --> <!-- //2.url-pattern defines matching mapping filtering (there can be multiple) --> <!-- //(1). Strings starting with "/" and ending with "/*" are used for path mapping. Such as "/xing/*" --> <!-- //(2). Starting with "*.", it is used for extended mapping. (extension match) --> <!-- //(3). A string containing only "/", specifying the current servlet as the default servlet for the application. Such as "/xing/*" --> <!-- //(4). Others are exact matches. Such as "/TestConnect" --> <servlet-mapping> <servlet-name>SpringMVC</servlet-name> <!-- <url-pattern>/</url-pattern> --> <url-pattern>/xing/*</url-pattern> </servlet-mapping> <listener> <description>HttpSessionListener监听器</description> <listener-class>com.proserver.common.controller.Test.Listener.MyServletContextListener</listener-class> </listener> <!-- //1. Filter configuration --> <filter> <filter-name>filterTest3</filter-name> <filter-class>com.proserver.common.controller.Test.filter.FilterTest3</filter-class> <init-param> <param-name>userName</param-name> <param-value>HelloWorld</param-value> </init-param> </filter> <!-- //1. Filter rule configuration --> <filter-mapping> <filter-name>filterTest3</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>