Spring在web.xml中的配置
来源:互联网 发布:matlab生成全是1的矩阵 编辑:程序博客网 时间:2024/05/16 15:04
在实际项目中spring的配置文件applicationcontext.xml是通过spring提供的加载机制,自动加载的容器中去,在web项目中,配置文件加载到web容器中进行解析,目前,spring提供了两种加载器,以供web容器的加载:一种是ContextLoaderListener,另一种是ContextLoaderServlet。这两种在功能上完全相同,只是一种是基于Servlet2.3版本中新引入的Listener接口实现,而另一种是基于Servlet接口实现,以下是这两种加载器在web.xml中的时机配置应用:
第一种:
<listener>
<listener-class>org.springframework.context.ContextLoaderListener</listener-class>
</listener>
另一种:
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
通过上面的配置,web容器会自动加载applicationcontext.xml初始化。
如果需要指定配置文件的位置,可通过context-param加以指定:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/myApplicationContext.xml</param-value>
</context-param>
之后,可以通过
WebApplicationContextUtils.getWebApplicationContext方法在web应用中获取applicationcontext的引用。
- spring在web.xml中的配置
- Spring在Web.xml中的配置
- Spring在web.xml中的配置
- spring上下文在web.xml中的配置
- spring在web.xml中的配置
- spring上下文在web.xml中的配置
- spring在web.xml中的配置
- spring在web.xml中的配置
- spring 在web.xml中的配置
- spring在web.xml中的配置
- spring在web.xml中的配置示例
- spring在web.xml中的配置
- spring的applicationContext.xml在web.xml中的配置详解
- spring在web.xml中和在struts中的不同配置
- spring在web.xml中和在struts中的不同配置
- spring在web.xml中和在struts中的不同配置
- spring在web.xml中和在struts中的不同配置
- spring在web.xml中和在struts中的不同配置
- input type="file"
- 模式以及划分信息
- REST服务开发实战
- 创建硬链接:Invalid cross-device link错误
- 黑马程序员:JAVA线程间的通信
- Spring在web.xml中的配置
- WEB的开始
- UNITY3D物理引擎。。感谢整理。。。
- Android总结笔记01:自定义View学习(一)
- 开源C++函数库Boost内存池使用与测试
- 网页上如何调用摄像头和麦克
- linux fork 笔记
- aix 一些问题收集
- 开发业务复杂型系统之杂谈(框架CodeIgniter)