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

  • 相关阅读:
    环境变量
    查看进程的环境变量
    shell打印彩色输出
    python使用smtplib发送邮件
    多线程实现ping扫描
    python ssh之paramiko模块使用
    Windows环境安装tesseract-ocr 4.00并配置环境变量
    Scrapy教程,亲测能用
    pycharm 调试 scrapy
    Python中元组,列表,字典的区别
  • 原文地址:https://www.cnblogs.com/hfultrastrong/p/10832903.html
Copyright © 2011-2022 走看看