spring在web.xml中的配置
在实际项目中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-mvc.xml spring-mybatis.xml web.xml log4j.properties,项目中需要用到的配置文件。直接可用。
spring在web.xml中和在struts中的不同配置..pdf
spring无web.xml零配置,使用javaconfig来进行spring配置,本项目使用maven管理,
本篇文章主要介绍了Spring mvc的web.xml配置说明,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
加载spring 文件,在web.xml中的配置
spring无web.xml的jdbctemplate配置
<param-value>/WEB-INF/spring-config.xml <!-- 备注:此所设定的参数,在JSP网页中可以使用下列方法来取得:${initParam.param_name} 若在Servlet可以使用下列方法来获得:String param_name=getServletContext...
这份文件 把javaEE 中web.xml中的基本配置都 写在里面了
NULL 博文链接:https://200cc.iteye.com/blog/2192843
spring在web.xml中和在struts中的不同配置.[收集].pdf
SpringMVC基于代码的配置方式(零配置,无web.xml) 本资源博客地址:http://blog.csdn.net/u013816347/
spring4的“所有jar包”+applicationContext.xml+web.xml====全套
ssm一个简单项目所需的xml配置文件,spring+springmvc+mybatis框架中用到了三个XML配置文件:web.xml,spring-mvc.xml,spring-mybatis.xml.第一个不用说,每个web项目都会有的也是关联整个项目的配置.第二个文件spring-...
主要介绍了Spring在web.xml中的配置详细介绍的相关资料,需要的朋友可以参考下
绍spring在web.xml中和在struts中的不同配置
主要介绍了Spring手动生成web.xml配置文件过程详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
主要介绍了Spring MVC的web.xml配置详解,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
SSM整合下的web.xml配置文件
java servlet spring web filter listenr
springMVC零配置,无web.xml,无spring配置,纯java