zoukankan      html  css  js  c++  java
  • ContextLoadListener & DispatcherServlet 加载顺序以及加载过程

    org.springframework.web.context.ContextLoaderListener 1
    org.springframework.web.servlet.DispatcherServlet 2

    SpringWebMvc中同时配置1和2

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:ApplicationContext.xml,classpath:RedisContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <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:SpringMvcContext.xml</param-value>
        </init-param>
    </servlet>

    因为1被配置在监听器标签,并实现ServletContextListener接口,所以当容器启动后,1会进行org.springframework.web.context.ContextLoaderListener#contextInitialized方法进行初始化。
    初始化后,此时项目处于等待状态,等待第一个请求到来,当第一个请求到达时,2才会进行实例化并调用。
    具体实例化过程,参见:https://www.cnblogs.com/hfultrastrong/p/10830517.html

  • 相关阅读:
    CentOS7.5 搭建MyCat1.6.6
    idea快速搭建springboot项目
    MySQL存储过程中变量及循环的使用
    windows 安装 jdk1.8并配置环境变量
    CentOS7.5安装JDK1.8
    CentOS7.2安装MySql5.7并开启远程连接授权
    PHP高级工程师面试
    每日英语
    静态化
    php分页实例及其原理
  • 原文地址:https://www.cnblogs.com/hfultrastrong/p/10832903.html
Copyright © 2011-2022 走看看