web应用中,Spring的启动方式

来源:互联网 发布:qq群验证模块源码 编辑:程序博客网 时间:2024/05/20 18:18

在web.xml文件中

通过web.xml配置加载spring上下文环境,其配置方式如下:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>


通过listener加载
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>


利用severlet类加载
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

原创粉丝点击