gpt4 book ai didi

java - Spring security hasRole() 给出错误 403 - 访问被拒绝

转载 作者:行者123 更新时间:2023-11-30 06:10:57 24 4
gpt4 key购买 nike

我正在尝试查看只有管理员可以查看的特定页面,但每次发出请求时都会收到错误消息。它似乎与我的安全上下文文件中的 hasRole() 一起使用。

错误只是说 HTTP 状态 403 - 当我请求查看管理 jsp 页面时访问被拒绝

安全上下文.xml:

<security:http use-expressions="true">
<security:intercept-url pattern="/admin" access="hasAnyRole('admin')" />
<security:form-login login-page="/login"
authentication-failure-url="/login?error=true" />
<security:logout logout-success-url="/loogedout" />
<security:intercept-url pattern="/createoffer" access="isAuthenticated()" />
<security:intercept-url pattern="/docreate" access="isAuthenticated()" />
<security:intercept-url pattern="/offercreated" access="isAuthenticated()" />
<security:intercept-url pattern="/" access="permitAll" />
<security:intercept-url pattern="/loggedout" access="permitAll" />
<security:intercept-url pattern="/newaccount" access="permitAll" />
<security:intercept-url pattern="/createaccount" access="permitAll" />
<security:intercept-url pattern="/accountcreated" access="permitAll" />
<security:intercept-url pattern="/static/**" access="permitAll" />
<security:intercept-url pattern="/login" access="permitAll" />
<security:intercept-url pattern="/offers" access="permitAll" />
<security:intercept-url pattern="/**" access="denyAll" />
</security:http>

我数据库中的两个表是用户(用户名、电子邮件、启用、密码)和权限(用户名、权限)。

谁能建议我的错误是什么或如何解决?

最佳答案

关于java - Spring security hasRole() 给出错误 403 - 访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34928751/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com