使用spring登录后重定向到请求的页面

时间:2016-09-21 07:52:54

标签: spring security redirect login

这是我的spring-security.xml

    <http auto-config="true" path-type="ant">
    <intercept-url pattern="/myaccount.html*" access="ROLE_CUSTOMER"/>       
    <intercept-url pattern="/viewpage.html*" access="ROLE_CUSTOMER"/>
    <form-login login-page="/login.html"
                authentication-success-handler-ref="ssoAuthenticationSuccessHandler"
                login-processing-url="/j_security_check" default-target-url="/login.html"
                authentication-failure-handler-ref="authenticationFailureHandler"/>
    <logout invalidate-session="true" success-handler-ref="ssoLogoutHandler" delete-cookies="JSESSIONID,loggedIn,_bt,slc_f,slc_t,_px_i,attempt_auto_login"/>
    <session-management session-fixation-protection="none"/>
</http>

如果用户访问某些网址,我想拦截他登录。需要用户将其重定向到原始请求页面后。

以上xml帮助我在用户访问viewpage.html时拦截,但在登录成功后,它不会将我带到viewpage.html。相反,它总是把我带到myaccount.html。

1 个答案:

答案 0 :(得分:0)

SavedRequestAwareAuthenticationSuccessHandler用作AuthenticationSuccessHandler的默认实现类。

这应该可以按预期工作。

我不确定authentication-success-handler-ref="ssoAuthenticationSuccessHandler"应该做什么,但请尝试查看SavedRequestAwareAuthenticationSuccessHandler并查看是否可以获得任何线索。

相关问题