- 浏览: 2268005 次
- 性别:
- 来自: 成都
文章分类
- 全部博客 (357)
- J2EE (49)
- JavaScript (40)
- Spring (19)
- Struts (5)
- CSS (8)
- Hibernate (16)
- Java (67)
- DWR (4)
- JSON (3)
- XFIRE (1)
- Tomcat (1)
- Ant (2)
- 设计模式 (2)
- 经典收藏 (2)
- JSP (10)
- Linux (0)
- WebLogic (11)
- myeclipse (13)
- Buffalo (4)
- 文件上传相关 (1)
- oracle (33)
- html (6)
- JSTL (3)
- SVN (2)
- GIT (1)
- 孙卫琴(Java网络编程精解) (1)
- DOM4J (2)
- Swing (1)
- AJAX (1)
- Eclipse (5)
- 日志组件 (3)
- PowerDesigner (1)
- Jquery (22)
- IT技术开发相关网址 (1)
- Nutz (1)
- 其它 (1)
- Velocity (3)
- WebService (1)
- MySql (2)
- Android (1)
- Maven (2)
- Quartz (11)
- Lucene (1)
- springsource (1)
- Junit (1)
- Activiti (0)
最新评论
-
yzlseu:
拼凑,没有营养
Activiti进阶—分配组任务 -
zhangsenhao:
非常赞!代码很清楚
SpringMVC3.0+MyIbatis3.0(分页示例) -
xiamw2000:
分页写得不对,应该是 : order by ${orderNa ...
SpringMVC3.0+MyIbatis3.0(分页示例) -
sheertewtw:
...
SpringMVC:上传与下载 -
kingtoon:
...
XSS之xssprotect
参考资料
1 Spring之ContextLoaderListener的作用
http://lei2006.blog.sohu.com/116206469.html
使用spring除了添加必要的jar包,另外在web.xml一定要加上启动spring的监听器,这样配置在xml文件中的bean才会初始化
如你在web.xml这样作了配置:(web.xml 2.4)
它会默认查找位于:WEB-INF/下的是否有一个文件名称为:applicationContext.xml
如果没有就会报错:
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:509)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:427)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:215)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4521)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5004)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:4999)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:117)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... 20 more
但在很多项目中可能会把配置文件集中管理,常见位置在:classpath下面,这样的话,你要在web.xml中在配置另外一个节点名称:
常见可能是这样:/WEB-INF/classes/applicationContext-*.xml
总之它是使用spring必须要配置的元素,一定不要少了
1 Spring之ContextLoaderListener的作用
http://lei2006.blog.sohu.com/116206469.html
使用spring除了添加必要的jar包,另外在web.xml一定要加上启动spring的监听器,这样配置在xml文件中的bean才会初始化
如你在web.xml这样作了配置:(web.xml 2.4)
<listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener>
它会默认查找位于:WEB-INF/下的是否有一个文件名称为:applicationContext.xml
如果没有就会报错:
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:509)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:427)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:215)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4521)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5004)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:4999)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:117)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... 20 more
但在很多项目中可能会把配置文件集中管理,常见位置在:classpath下面,这样的话,你要在web.xml中在配置另外一个节点名称:
<context-param> <param-name> contextConfigLocation </param-name> <param-value> classpath*:applicationContext.xml </param-value> </context-param>
常见可能是这样:/WEB-INF/classes/applicationContext-*.xml
总之它是使用spring必须要配置的元素,一定不要少了
发表评论
-
Spring Task Schedule
2017-06-24 08:46 721链接:http://docs.spring.io/spring ... -
Spring之JDBC模板(手写)
2011-10-24 14:44 4262一 模板父类: SpringBaseDAO.java im ... -
Sprint之java.util.Time
2011-07-06 16:17 1636参考资料 1 在Spring中使用JDK Timer进行任务调 ... -
java.util.Time结合Spring发送Email
2011-07-06 15:02 1937参考资料 1 Web项目下应用Java Timer定时器 ht ... -
Spring之Email<封装了常用的四种发送Email的方法(TEXT,HTML,IMG,FILE)>
2011-07-05 11:47 29651参考资料 1 Spring邮件发送(可带附件,模板,群发,异 ... -
SpringMVC:生成Excel和PDF
2011-06-07 17:18 25309参考资料 1 用spring MVC 生成Excel和PDF ... -
SpringMVC:整合JQUERY与JSON
2011-06-03 10:45 67699参考资料 1 Spring3 MVC 笔记(二) —json+ ... -
SpringMVC+JDBC:分页示例
2011-06-01 17:22 21998一 环境:XP3+Oracle10g+MyEclipse6+( ... -
SpringMVC:上传与下载
2011-06-01 16:46 27184参照了网上相关代码 注意事项: 1 springmvc.xm ... -
Spring配置JNDI(WebLogic92)NameNotFoundException: Unable to resolve解决
2011-03-15 16:01 22136请参见: Struts2.2+Spring3.1+Hiber ... -
Spring配置JNDI(Tomcat7)
2011-03-15 13:02 12039请参见: Struts2.2+Spring3.1+Hibern ... -
Struts2.2+Spring3.1+Hibernate3.6整合(登录示例及CRUD操作)
2011-03-01 13:26 20362一 运行环境: XP3+Myeclipse6.6+Tomcat ... -
spring整合hibernate关于 session的管理<三种方式>
2011-02-23 13:22 2375转载:spring整合hibernate关于 session的 ... -
Spring3 MVC Annotaction入门(登录示例)
2011-01-29 16:43 18840浏览资料 1 SpringMVC入门实例及详细讲解 http: ... -
Spring MVC入门(登录示例)
2011-01-26 10:09 17133一 环境: Myeclipse6.6+JDK1.5+Tomca ... -
spring3.0.5启动报错:org.springframework.beans.factory.BeanDefinitionStoreException
2011-01-24 16:33 42303一 开发环境:JDK5+Spring3.0.5+Myeclip ... -
转载:Spring(一)为什么要使用spring
2010-07-30 09:28 1265转载: Spring(一)为什么要使用spring http: ... -
spring的jar包详解
2009-09-19 11:05 1386转载:http://www.blogjava.net/li ...
相关推荐
Spring的监听器ContextLoaderListener的作用
java解决org.springframework.web.context.ContextLoaderListener
二、 使用 Spring 的器监听器 ContextLoaderListener o1. maven依赖pom.xml o2. 注册监听器 ContextLoaderListener o3. 指定 Spring 配置文件的位置 o4. 获取Spring容器对象 在 Web 项目中使用 Spring 框架,首先...
org.springframework.web.context.ContextLoaderListener.class org.springframework.web.context.ContextLoaderServlet.class org.springframework.web.context.ServletConfigAware.class org.springframework.web....
Spring framework 5.1.5源码 Main: spring-web/org.springframework.web.context.ContextLoaderListener
17 <listener-class>org.springframework.web.context.ContextLoaderListener 18 19 20 21 <filter-name>encodingFilter 22 <filter-class>org.springframework.web.filter.CharacterEncodingFilter 23 24 ...
org.springframework.web.context.ContextLoaderListener </listener> <!-- Spring MVC 的Servlet,它将加载WEB-INF/annomvc-servlet.xml 的 配置文件, 以启动Spring MVC模块--> <servlet-name>annomvc ...
org.springframework.web.context.ContextLoaderListener <listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener>
org.springframework.web.context.ContextLoaderListener 4.配置spring的配置文件(可以查看WEB-INF里面的applicationContext.xml文件) 注意:如果是默认,一定要放在WEB-INF中并文件名为...
spring/applicationContext.xml </param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> ApplicationContext * * * *...
下面我们使用ContextLoaderListener作为载入器作一个详细的分析,这个Servlet的监听器是根上下文被载入的地方,也是整个 Spring web应用加载上下文的第一个地方;从加载过程我们可以看到,首先从Servlet事件中得到...
09. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 10. </listener> 11. 12. <servlet> 13. <servlet-name>spring</servlet-name> 14. <servlet-class>org.spring...
在web应用启动读取web.xml时,发现配置了ContextLoaderListener,而ContextLoaderListener实现了ServletCo
struts2与spring的整合。导入struts2-spring-... spring监听器对应的API类为:org.springframework.web.context.ContextLoaderListener。 struts2-spring-plugin包为我们将struts2的对象工厂设置为spring的IoC容器,
Web 应用程序使用 Spring Web 侦听器初始化,例如web.xml org.springframework.web.context.ContextLoaderListener 。 Spring Web 侦听器使用web.xml的contextConfigLocation上下文参数进行初始化。 此设置的...
mybatis实战教程mybatis in action之五与spring3集成附源码 mybatis实战教程mybatis in action之六与Spring MVC 的集成 mybatis实战教程mybatis in action之七实现mybatis分页源码下载 mybatis实战教程mybatis in ...
org.springframework.web.context.ContextLoaderListener <filter-name>encodingFilter org.springframework.web.filter.CharacterEncodingFilter <param-name>encoding ...
参考(2)Eclipse和IDEA配置Maven2.Spring版本:5.0.73.MVC:Spring MVC配置(1)jar包:spring-webmvc.jar(2)web.xml配置SpringMVC监听类:org.springframework.web.context.ContextLoaderListener(3)SpringMVC核心配置...
<listener-class>org.springframework.web.context.ContextLoaderListener <servlet-name>test <servlet-class>org.springframework.web.servlet.DispatcherServlet <load-on-startup>1 <servlet-name>...
ContextLoaderListener ContextLoaderPlugIn ContextLoaderServlet ContextRefreshedEvent ContextSingletonBeanFactoryLocator ControlFlow ControlFlowFactory ControlFlowFactory.Jdk13ControlFlow ...