春季-没有找到WebApplicationContext:没有注册ContextLoaderListener吗? [英] Spring - No WebApplicationContext found: no ContextLoaderListener registered?
本文介绍了春季-没有找到WebApplicationContext:没有注册ContextLoaderListener吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试运行Spring项目时出现以下错误
I am getting the following error while trying to run a Spring project
HTTP Status 500 - java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
尽管在我的web.xml
上添加了列表器.我仍然收到此错误.以下是我添加到我的web.xml中的侦听器:
Inspite of adding the listner on to my web.xml
. I am still getting this error. Below is the listener I have added to my web.xml :
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/HelloWebRedirect-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
有人可以在这方面帮助我吗?
Can someone help me out in this regard?
推荐答案
您好@ user2681868我也面临着同样的问题,这是您应该遵循的步骤.
Hi @user2681868 I was also facing the same problem here are the steps you should follow.
1)在web.xml中定义此
1) in web.xml define this
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
2)使用此内容在web-inf中创建一个applicationContext.xml
2) create a applicationContext.xml in web-inf with this content
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
</beans>
这篇关于春季-没有找到WebApplicationContext:没有注册ContextLoaderListener吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文