【发布时间】:2012-02-27 23:33:15
【问题描述】:
在我的应用程序中,我使用的是 Spring Security 3.0,在用于拦截“身份验证后”的类中,我有类似的内容:
public class CustomAuthenticationHandler extends SavedRequestAwareAuthenticationSuccessHandler {
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
SavedRequest savedRequest = new HttpSessionRequestCache().getRequest(request, response);
...
}
}
<security:http>
<security:form-login login-page="/login/" always-use-default-target="false" authentication-success-handler-ref="customAuthenticationHandler" authentication-failure-url="/login/?login_error=1"/>
...
</security:http>
<bean id="customAuthenticationHandler" class="org.myproject.CustomAuthenticationHandler"/>
当我从应用程序内的通用页面“X”登录时,我希望在成功验证后重定向到“X”,但我总是登陆主页。 上面的“savedRequest”变量总是返回 null。是否缺少任何特定设置?如何获得正确的重定向?
【问题讨论】:
标签: java spring spring-security