HTTP状态403 - 访问被拒绝Spring security

时间:2015-09-13 08:51:34

标签: java spring spring-mvc spring-security

我已将Spring安全性添加到我的项目中并将其配置为

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd">

     <http>
        <intercept-url pattern="/add-job**" access="hasRole('USER')" />
        <form-login  
            login-page="/login" 
            default-target-url="/"
            always-use-default-target="true"/>
        <logout />
    </http>

    <authentication-manager>
        <authentication-provider>
            <user-service>
            <user name="admin" password="admin" authorities="ROLE_ADMIN" />
            </user-service>
        </authentication-provider>
    </authentication-manager>

</beans:beans>

通过以上配置,当我转到/add-job时,它会将我重定向到\login,登录成功后我转到/add-job它会显示错误 Access Denied Message

我有没有错。

0 个答案:

没有答案