spring Security登录报错:Access is denied (user is anonymous); redirecting to authentication entry point

错误描述

最近在做黑马的管理系统练习,在使用spring security进行登录验证时报错:Access is denied (user is anonymous); redirecting to authentication entry point

报错信息如下:

在这里插入图片描述
使用的spring-security.xml文件如下:

在这里插入图片描述

错误分析

我在网上查阅了各种导致Access is denied (user is anonymous)的解决办法,都无法解决我的问题,我转换思路,由于我是在未进入登录页面是就出现此异常,说明可能是<security:intercept-url pattern="/**" access="ROLE_USER"/>权限验证拦截导致的,然后我查看我的spring-security.xml中的拦截路径

webapp的目录结构如下:

在这里插入图片描述

由于<security:http pattern="/login.jsp" security="none" ></security:http>中 pattern是读取webapp目录下的资源,我的jsp文件均放在webapp的二级目录pages中,所以login.jsp页面无法被阻止拦截,在访问时被直接拦截。

解决办法

后对配置文件中的路径进行了修改,可正常进入登录页面。

修改后的spring-security.xml如下:

在这里插入图片描述

补充

<security:form-login>中login-page,authentication-success-forward-url,authentication-failure-forward-url读取的均为webapp下资源

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值