五、Spring与web项目的整合之ContextLoaderListener

  ContextLoaderListener可以让Spring容器随项目的启动而创建,并随项目的关闭而销毁!

<context-param>
        <param-name>contextConfigLocation</param-name>
        <!-- spring监听器加载的配置文件 -->
        <param-value>classpath:spring/applicationContext.xml</param-value>
    </context-param>
<listener>
        <!--ContextLoaderListener监听器的作用就是启动Web容器时,自动装配ApplicationContext的配置信息-->
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

猜你喜欢

转载自blog.csdn.net/panchang199266/article/details/81914016
今日推荐