Tomcat加载应用程序配置文件顺序

对于三大框架,例如ssh或ssm,在Tomcat容器启动时配置文件加载顺序是?

针对这样的疑问,我大概知道每个项目的加载都是从web.xml开始的,所以我们以下面的配置文件为例,说明加载过程,我的项目web.xml配置文件如下:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="2.5" xmlns="
    xmlns:xsi="
    xsi:schemaLocation=" 
    "> 
 
    <context-param> 
        <param-name>log4jConfigLocation</param-name> 
        <param-value>/WEB-INF/classes/log4j.properties</param-value> 
    </context-param> 
    <listener> 
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> 
    </listener> 
 
    <!--  户登录安全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>UTF-8</param-value> 
        </init-param> 
    </filter> 
    <filter-mapping> 
        <filter-name>encodingFilter</filter-name> 
        <url-pattern>/*</url-pattern> 
    </filter-mapping> 
 
         
    <!--  添加CAS filter  begin --> 
    <!-- 填写退出的URL --> 
    <context-param> 
        <param-name>casServerLogoutUrl</param-name> 
        <param-value>https://cass.cdv.com:8443/cas/logout</param-value> 
    </context-param> 
    <context-param> 
        <param-name>serverName</param-name> 
        <param-value>:8080</param-value> 
    </context-param> 
    <context-param> 
        <param-name>casServerLoginUrl</param-name> 
        <param-value>https://cass.cdv.com:8443/cas/login</param-value> 
    </context-param> 
    <listener> 
        <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class> 
    </listener> 
 
    <!-- CAS sign out --> 
    <filter> 
        <filter-name>CAS Single Sign Out Filter</filter-name> 
        <!--  the class to cometrue Filter Interface --> 
        <filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class> 
    </filter> 
    <filter-mapping> 
        <filter-name>CAS Single Sign Out Filter</filter-name> 
        <!-- the webpage to filter  --> 
        <url-pattern>/*</url-pattern> 
    </filter-mapping> 
    <!--单点退出配置--> 
    <!-- CAS login首次登陆拦截跳转登陆页面 --> 
    <filter> 
        <filter-name>CAS Filter</filter-name> 
        <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class> 
        <!-- 初始化filter,默认的设置. --> 
        <init-param> 
            <param-name>casServerLoginUrl</param-name> 
            <!-- 统一认证服务器地址 --> 
                    <param-value>https://cass.cdv.com:8443/cas/login</param-value> 
 
        </init-param> 
        <init-param> 
            <param-name>serverName</param-name> 
            <!-- 项目所在的服务器地址和端口号,认证服务器回调的URL--> 
            <param-value>:8080</param-value> 
        </init-param> 
    </filter> 
 
    <!-- 过滤哪些网站 --> 
    <filter-mapping> 
        <filter-name>CAS Filter</filter-name> 
        <!-- 项目中所要拦截的url --> 
        <url-pattern>/*</url-pattern> 
     
    </filter-mapping> 
 
    <!-- CAS Validation Filter 再次验证ticket--> 
    <filter> 
        <filter-name>CAS Validation Filter</filter-name> 
        <filter-class> 
            org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class> 
        <!-- 初始化Filter,默认设置. --> 
        <init-param> 
            <param-name>casServerUrlPrefix</param-name> 
            <param-value>https://cass.cdv.com:8443/cas</param-value> 
 
        </init-param> 
        <init-param> 
            <param-name>serverName</param-name> 
            <!-- 验证成功转到的地址 --> 
            <param-value>:8080</param-value> 
        </init-param> 
    </filter> 
    <!-- 过滤所有的网页 --> 
    <filter-mapping> 
        <filter-name>CAS Validation Filter</filter-name> 
        <!-- 项目中所要拦截的url --> 
        <url-pattern>/*</url-pattern> 
    </filter-mapping> 
     
    <listener> 
        <listener-class>com.cdv.vms.web.listener.SessionListener</listener-class> 
    </listener> 
 
 
    <!--  添加CAS filter  end --> 
 
    <!--  添加security filter 控制菜单的显示和隐藏  begin --> 
    <filter> 
        <description>login security filter</description> 
        <display-name>SecurityFilter</display-name> 
        <filter-name>SecurityFilter</filter-name> 
        <filter-class>com.cdv.ms.web.filter.SecurityFilter</filter-class> 
        <!-- 不需要过滤则直接转到主界面  /user/toMain/--> 
        <init-param> 
            <param-name>noFilter</param-name> 
            <param-value>main.jsp</param-value> 
        </init-param> 
        <init-param> 
            <param-name>noFilter1</param-name> 
            <param-value>/publish/showV/</param-value> 
        </init-param> 
    </filter> 
    <!-- 过滤内容 --> 
    <filter-mapping> 
        <filter-name>SecurityFilter</filter-name> 
        <url-pattern>/*</url-pattern> 
    </filter-mapping> 
    <!--  添加security filter  end --> 
 
 
    <servlet> 
        <servlet-name>springMVC</servlet-name> 
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
        <init-param> 
            <param-name>contextConfigLocation</param-name> 
            <param-value>classpath:springMVC.xml,classpath:applicationContext.xml</param-value> 
        </init-param> 
        <load-on-startup>1</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
        <servlet-name>springMVC</servlet-name> 
        <url-pattern>/</url-pattern> 
    </servlet-mapping> 
    <!-- upload start --> 
    <servlet> 
        <servlet-name>TokenServlet</servlet-name> 
        <servlet-class>com.cdv.upload.servlet.TokenServlet</servlet-class> 
        <load-on-startup>0</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
        <servlet-name>TokenServlet</servlet-name> 
        <url-pattern>/tk</url-pattern> 
    </servlet-mapping> 
    <servlet> 
        <servlet-name>StreamServlet</servlet-name> 
        <servlet-class>com.cdv.upload.servlet.StreamServlet</servlet-class> 
        <load-on-startup>0</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
        <servlet-name>StreamServlet</servlet-name> 
        <url-pattern>/upload</url-pattern> 
    </servlet-mapping> 
    <servlet> 
        <servlet-name>FormDataServlet</servlet-name> 
        <servlet-class>com.cdv.upload.servlet.FormDataServlet</servlet-class> 
        <load-on-startup>0</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
        <servlet-name>FormDataServlet</servlet-name> 
        <url-pattern>/fd</url-pattern> 
    </servlet-mapping> 
    <!-- upload end --> 
     
    <error-page> 
        <error-code>404</error-code> 
        <location>/common/404.jsp</location> 
    </error-page> 
    <error-page> 
        <error-code>505</error-code> 
        <location>/common/505.jsp</location> 
    </error-page> 
 
    <!--  welcome main.jsp --> 
    <welcome-file-list> 
        <welcome-file>main.jsp</welcome-file> 
    </welcome-file-list> 
</web-app> 

Tomcat容器加载

一、加载顺序

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/8d1719253b62616eae37276a1a90fb80.html