我在我的應(yīng)用程序中使用Spring Security 4.2.2.RELEASE。一旦發(fā)生超時(shí),然后用戶點(diǎn)擊任何URL,它就會(huì)被重定向到注銷頁面,一旦認(rèn)證成功,它就會(huì)重定向到默認(rèn)的主頁,而不是請求的頁面。web xml如下:<bean id="logoutSuccessHandler"
class="org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler">
<property name="useReferer" value="true"/>
</bean>
<security:form-login
login-page="/login"
authentication-failure-url="/login_error"
username-parameter="username"
password-parameter="password"
default-target-url="/home"
always-use-default-target="false"
/>我希望它在身份驗(yàn)證正確后重定向到請求的頁面。我已經(jīng)讀過Spring Security默認(rèn)提供此功能。但它沒有用,所以我試圖使用SimpleUrlLogoutSuccessHandler來實(shí)現(xiàn)。但仍無法找到方法。那么這里可能出現(xiàn)什么問題?
2 回答

湖上湖
TA貢獻(xiàn)2003條經(jīng)驗(yàn) 獲得超2個(gè)贊
好吧,你需要實(shí)施SimpleUrlAuthenticationSuccessHandler
。這有助于您處理重定向。
<http> <intercept-url pattern="/login" access="permitAll"/> <intercept-url pattern="/**" access="isAuthenticated()"/> <form-login authentication-success-handler-ref="refererHandler" /></http><beans:bean class="RefererRedirectionAuthenticationSuccessHandler" name="refererHandler"/>
并執(zhí)行如下:
public class RefererRedirectionAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler implements AuthenticationSuccessHandler { public RefererRedirectionAuthenticationSuccessHandler() { super(); setUseReferer(true); } }
添加回答
舉報(bào)
0/150
提交
取消