ITeye博客

myeclipse600的博客

myeclipse600 · 共 5 篇文章

Spring监听器ContextLoaderListener的作用

在SSH项目中我们自动加载spring配置文件需要在web.xml文件中添加一段配置: Xml代码 <context-param> <param-name> contextConfigLocation </param-name> <param-value> classpath*:applicationContext-*.xml </param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </…

2013-05-10 16:29 · Spring · 评论(0)

在WEB工程下搭建spring2.5

1.创建WEB工程 2.添加spring2.5.6必须得jar包,spring.jar和common-logging.jar, 3.新建spring的配置文件,可以是一或多个配置文件,开发中大部分都会是多个配置文件 4.在web.xml来加载spring Xml代码 <context-param> <param-name> contextConfigLocation </param-name> <param-value> /WEB-INF/applicationContext-common.xml,/WEB-INF/applicationContext-dao.xml,/WEB-INF/ap…

2013-05-10 16:29 · Spring · 评论(0)

web.xml文件中<context-param>元素的作用

1.启动一个WEB项目的时候,容器(如:Tomcat)会去读它的配置文件web.xml.读两个节点: <listener></listener> 和 <context-param></context-param> 2.紧接着,容器创建一个ServletContext(上下文),这个WEB项目所有部分都将共享这个上下文. 3.容器将<context-param></context-param>转化为键值对,并交给ServletContext. 4.容器创建<listener></listener>中的类实例,即创建监听. 5.在监听中会有contextInitialized(ServletCo…

2013-05-10 16:27 · Spring · 评论(0)

web.xml文件中的Listener元素的作用

Listener 的作用非常类似于load-on-startup Servlet。用于在Web 应用启动时,启动某些后台程序,这些后台程序负责为系统运行提供支持。 Listener 与load-on-startup Servlet 的区别在于: Listener 的启动时机比load-on-startup Servlet 早,只是Listener 是Servlet 2.3 规范之后才出现的。 使用Listener 只需要两个步骤: (1)创建Listener 实现类。 (2)在web.xml 文件中配置Listener。 一、创建Listener 实现类 创建Listener 类必须实现Se…

2013-05-10 16:27 · Spring · 评论(0)

如何在spring中读取properties配置文件里面的信息

如何在spring中读取properties配置文件里面的信息。 <!-- 正文开始 --> 一般来说。我们会将一些配置的信息放在。properties文件中。 然后使用${}将配置文件中的信息读取至spring的配置文件。 那么我们如何在spring读取properties文件呢。 1.首先。我们要先在spring配置文件中。定义一个专门读取properties文件的类. 例: <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer…

2013-05-10 16:25 · Spring · 评论(0)