小编Jee*_*ahu的帖子

Spring Security:收到错误“服务器理解了请求但拒绝授权”

使用Spring Security运行应用程序时,我在所有浏览器上都遇到以下错误:

“服务器理解了请求,但拒绝授权”

我尝试通过将“ spring-security.xml”文件中的“角色”从“ ROLE_ADMIN”更改为“ ROLE_USER”。

下面是“ spring-security.xml”

<http auto-config="true">
    <intercept-url pattern ="/admin" access = "hasRole('ROLE-USER')"/>
    </http>
    <authentication-manager>
        <authentication-provider>
        <user-service>
            <user name = "abc" password = "xyz" authorities="hasRole('ROLE-USER')" />
        </user-service>
        </authentication-provider>
    </authentication-manager>
Run Code Online (Sandbox Code Playgroud)

下面是SpringController类:

@Controller
public class SpringController {



@RequestMapping(value = "/")
    public String homePage() {
        return "HomePage";
    }
    @RequestMapping(value="/admin", method=RequestMethod.GET)
    public String loginPage() {
        return "login";
}
Run Code Online (Sandbox Code Playgroud)

已加载HomePage.jsp和login.jsp页面的属性,但是在login.jsp上传递凭据后出现错误:

HTTP状态403 –禁止


类型:状态报告

消息:访问被拒绝

描述:服务器理解了该请求,但拒绝对其进行授权。


Apache Tomcat / 7.0.90

web.xml spring-security

5
推荐指数
1
解决办法
4569
查看次数

标签 统计

spring-security ×1

web.xml ×1