-----No WebApplicationContext found: no ContextLoaderListener registered?-----
spring中提供 ContextLoaderListenter类,用来加载context的xml文件。
spring为struts提供ContextLoaderPlugIn类,此类也可以加载context的xml文件。
区别在于,两种方式加载的WebApplicationContext,以不同的Key存放在ServletContext中。而如果你定义了HibernateFilter的话,spring会利用WebApplicationContextUtils来获取WebApplicationContext,而此类并不识别ContextLoaderPlugIn类所加载的上下文,此时便会抛出异常: No WebApplicationContext found: no ContextLoaderListener registered?
利用ContextLoaderListenter来加载dao、service级别的context,而对于struts的action,用ContextLoaderPlugIn加载。
出现了No WebApplicationContext found: no ContextLoaderListener
registered异常,此问题产生的原因是因他的资源文件没加载进来所以找不到文件引起,于是我在web.xml中加入了如下语句:
<!-- Spring ApplicationContext配置文件的路径,可使用通配符,多个路径用,号分隔此参数用于后面的Spring-Context loader -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param>
分享到:
相关推荐
Spring把Bean放在这个容器中,普通的类在需要的时候,直接用getBean()方法取出
- Refreshing Root WebApplicationContext: startup date [Tue Jun 14 11:08:28 CST 2011]; root of context hierarchy - Loading XML bean definitions from file [E:\Eclipse_C\workspace\MyStrutsTest\WebRoot\...
Spring获取webapplicationcontext,applicationcontext几种方法详解
58:22,539 INFO ] org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.(AutowiredAnnotationBeanPostProcessor.java:153) - JSR-330 'javax.inject.Inject' annotation found and ...
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system properly. 2009-8-29 14:02:12 org.apache.catalina.core....
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\...
主要介绍了Spring MVC之WebApplicationContext的相关资料,需要的朋友可以参考下
注解配置SpringMVC原理简述1. 准备知识1.1 两个应用上下文1.2 ServletContext配置方法(Configuration Methods)1.3 运行时插拔1.4 SpringServletContainerInitializer1.4.1 AbstractContextLoaderInitializer1.4.2 ...
Spring TestContext Framework是spring-test模块中提供的一个测试框架,能够用于单元测试和集成测试。
WebApplicationContext:web环境使用的容器 注解 创建对象 Component:不分层的注解 Controller:web层 Service:service层 Repository:dao层 管理对象 注入 AutoWired Qualifier Resource ...
WebApplicationContext: 如转载请注明,转载自:关注Java[http://www.gbsou.com] 本文链接: http://www.gbsou.com/2009/08/11/214.html - - Java代码 public interface WebApplicationContext extends ...
WebApplicationContext配置类,需要根据具体的业务逻辑进行配置,比如缓存门面类的配置 * 需要在web端工程里具体配置 */ @Configuration @EnableAspectJAutoProxy // 相当于 xml 中的 @EnableTransactionManagement ...
Spring Web MVC开发 xml配置文件格式,无bean之类 Spring Web MVC开发配置文件 applicationContext
ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(); 或者 ApplicationContext ac = WebApplicationContextUtils.getRequiredWebApplicationContext(); 这是在action以外的地方拿...
Spring的注入在Servlet中使用:在Servlet中使用Spring注入的信息,需要WebApplicationContext这个专门为Web准备的应用上下文
本文是在Spring+Struts构建的轻量级框架基础上,通过让Buffalo用Spring放在ServletContext里面的 WebApplicationContext(ContextLoaderPlugIn实现把WebApplicationContext的实例放在了 ServletContext中来实现了一...
可以通过 WebApplicationContextUtils.getWebApplicationContext(ServletActionContext.getServletContext()); 来获取
ApplicationContext cxt = WebApplicationContextUtils.getWebApplicationContext(this.getServletConfig().getServletContext()); Workflow wf = (Workflow)cxt.getBean("workflow"); 用osworkflow自带的designer把...
这个jar文件包含Web应用开发时,用到Spring框架时所需的核心类, 包括自动载入WebApplicationContext特性的类、Struts与JSF集成类、文件上传的支持类、Filter类和大量工具辅助类。 spring的核心类,提供了核心HTTP...
这个简单的例子演示了在 web 应用程序中使用的 Spring 容器,即org.springframework.web.context.WebApplicationContext Web 应用程序使用 Spring Web 侦听器初始化,例如web.xml org.springframework.web.context...