在我的项目中,我用
DefaultSavedRequest它满足了我的要求。
DefaultSavedRequest成功认证后,AbstractAuthenticationProcessingFilter和SavedRequestAwareWrapper使用该类重现请求。ExceptionTranslationFilter在身份验证异常时存储此类的实例。
https://docs.spring.io/spring-
security/site/docs/4.1.2.RELEASE/apidocs/org/springframework/security/web/savedrequest/DefaultSavedRequest.html
@Overridepublic void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { DefaultSavedRequest defaultSavedRequest = (DefaultSavedRequest) session.getAttribute("SPRING_SECURITY_SAVED_REQUEST"); if(defaultSavedRequest != null){ String targetURL = defaultSavedRequest.getRedirectUrl(); redirectStrategy.sendRedirect(request, response, targetURL); return; }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)