0

登录成功后。我没有被重定向到 /admin/notifications 的原因可能是什么?我登录时在“contextpath/”输入。我错过了什么?

<!-- Spring security -->
<security:global-method-security secured-annotations="enabled"/>

<security:http pattern="/admin/login" security="none" />
<security:http pattern="/resources/public/**" security="none" />
<security:http auto-config="true" use-expressions="true" pattern="/admin/**" authentication-manager-ref="authenticationManager">
    <security:intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')"/>
    <security:form-login login-page="/admin/login" default-target-url="/admin/notifications" always-use-default-target="true"  authentication-failure-url="/admin/login?error=1" login-processing-url="/admin/j_spring_security_check"/>
    <security:logout invalidate-session="true" delete-cookies="" logout-url="/admin/logout" logout-success-url="/admin/login"/>
</security:http>
<security:http auto-config="true" use-expressions="true" ></security:http>

编辑:身份验证管理器。它存在于主应用程序上下文中包含的另一个 xml 文件中。

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

这是我的控制器

@Controller
@RequestMapping("/admin/notifications")
public class NotificationControllerAdmin {

    @ResponseStatus(HttpStatus.OK)
    @RequestMapping(method = RequestMethod.GET)
    public String getNotifications(Model model){
        return "admin/notifications/notifications";
    }
}
4

1 回答 1

0

第二个 spring-security 配置块<security:http auto-config="true" use-expressions="true" >可能会覆盖第一个中指定的所有设置。

于 2013-11-13T11:35:12.070 回答