春季安全性未找到WebApplicationContext

编程入门 行业动态 更新时间:2024-10-25 00:30:01
本文介绍了春季安全性未找到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

本文发布于:2023-10-29 09:48:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539377.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:未找到   安全性   春季   WebApplicationContext

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!