【SSH错误一】javax.servlet.ServletException: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered错误

struts1.2+hibernate3.1+spring2.0

在开发中遇到如下错误:

javax.servlet.ServletException: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered错误

解决方案:

方案一:在web.xml下添加spring配置文件的路径和监听器

步骤1.添加spring配置文件applicationContext.xml的路径
<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>/WEB-INF/applicationContext.xml</param-value>

(注:如在src下,则为/applicationContext.xml)

</context-param>

步骤2:添加监听器
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

方案二:直接在web.xml里配置spring插件

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> 
   <set-property property="contextConfigLocation"           value="/WEBINF/classes/applicationContext.xml" />
</plug-in>

附:MyEclipse 5.5 开发 Spring + Struts + Hibernate 的详解视频http://www.blogjava.net/beansoft/archive/2007/10/07/150877.html

posted @ 2012-11-09 11:23  风语菡  阅读(2319)  评论(0编辑  收藏  举报