首页 > 解决方案 > 当 Spring Security 中的会话超时时,SavedRequestAwareAuthenticationSuccessHandler 无法按预期工作

问题描述

4.2.2.RELEASE在我的应用程序中使用 Spring Security。一旦会话超时发生,然后如果用户单击任何 URL,它将被重定向到注销页面,一旦身份验证成功,它会重定向到默认主页,而不是先前请求的页面。

因此,我尝试通过将以下配置添加到 servlet.xml 文件来解决此问题。

  <security:form-login
            login-page="/login"
            authentication-failure-url="/login_error"
            username-parameter="username"
            password-parameter="password"
            always-use-default-target="false"
            authentication-success-handler-ref="authenticationSuccessHandler"
            />

 <security:intercept-url pattern="/login" access="permitAll"/>

 <bean id="authenticationSuccessHandler" class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
    <property name="useReferer" value="true" />
</bean>

这里可能出了什么问题?请有人解释为什么这不起作用?

标签: springjakarta-eespring-security

解决方案


推荐阅读