J2EE进阶(五)Spring在web.xml中的配置
来源:互联网 发布:python 模拟火势蔓延 编辑:程序博客网 时间:2024/06/05 18:57
J2EE进阶(五)Spring在web.xml中的配置
前言
在实际项目中spring的配置文件applicationcontext.xml是通过spring提供的加载机制自动加载到容器中。在web项目中,配置文件加载到web容器中进行解析。目前,spring提供了两种加载器,以供web容器的加载:一种是ContextLoaderListener,另一种是ContextLoaderServlet。这两种在功能上完全相同,只是前一种是基于Servlet2.3版本中新引入的Listener接口实现,而后一种是基于Servlet接口实现,以下是这两种加载器在web.xml中的配置应用:
ContextLoaderListener
<listener><listener-class>org.springframework.context.ContextLoaderListener</listener-class></listener>
ContextLoaderServlet
<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的引用。
美文美图
1 0
- J2EE进阶(五)Spring在web.xml中的配置
- J2EE 应用 proxool连接池,在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在web.xml中的配置
- spring的applicationContext.xml在web.xml中的配置详解
- spring在web.xml中和在struts中的不同配置
- spring在web.xml中和在struts中的不同配置
- spring在web.xml中和在struts中的不同配置
- 奶牛排队 (Standard IO)
- lua-string-resty的aes加密解密,无法和python的aes进行对接
- 从内存角度解析Java字符编码
- Springmvc
- 137. Single Number II LeetCode
- J2EE进阶(五)Spring在web.xml中的配置
- 数据结构与算法MOOC习题解题报告(PART 1:第6课-第8课)与PART 1总结
- RecyclerView的 item侧滑拖动、添加head、footview、下拉刷新。
- git Permission denied (publickey) 问题
- zookeeper原理
- (转)知乎的提问--服务器端测试主要包含什么?
- iOS-最全的App上架教程
- Hibernate多对一与一对多
- 哥德巴赫猜想