本文介绍了春季安全性未找到WebApplicationContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Spring Security的新手
I am new to spring security
我有web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="java.sun/xml/ns/javaee" xmlns:xsi="www.w3/2001/XMLSchema-instance" xsi:schemaLocation="java.sun/xml/ns/javaee java.sun/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/applicationContext-security.xml </param-value> </context-param> <servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list>
applicationContext-security.xml
applicationContext-security.xml
<?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="www.springframework/schema/security" xmlns:xsi="www.w3/2001/XMLSchema-instance" xmlns:beans="www.springframework/schema/beans" xsi:schemaLocation="www.springframework/schema/beans www.springframework/schema/beans/spring-beans.xsd www.springframework/schema/security www.springframework/schema/security/spring-security-3.0.xsd"> <http auto-config="true"> <intercept-url pattern="/register.html" access="IS_AUTHENTICATED_ANONYMOUSLY" /> <intercept-url pattern="/*" access="ROLE_USER, ROLE_ADMIN" /> <logout logout-url="/logout"/> </http> <beans:bean id="myUserDetailsService" class="labas.spring.service.UserDetailsImp"/> <authentication-manager> <authentication-provider user-service-ref='myUserDetailsService'/> </authentication-manager>
为什么我运行它时会得到
some why when I run it I get
java.lang.IllegalStateException:未找到WebApplicationContext:未注册ContextLoaderListener吗?
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
怎么了?
推荐答案您尚未声明根Webapp上下文-您已添加contextConfigLocation,但未添加使用它的侦听器:
You haven't declared the root webapp context - you've added the contextConfigLocation, but not the listener that uses it:
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>更多推荐
春季安全性未找到WebApplicationContext
发布评论