我在我的应用程序中使用Spring Security 4.2.2.RELEASE。一旦发生超时,然后用户点击任何URL,它就会被重定向到注销页面,一旦认证成功,它就会重定向到默认的主页,而不是请求的页面。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"
/>我希望它在身份验证正确后重定向到请求的页面。我已经读过Spring Security默认提供此功能。但它没有用,所以我试图使用SimpleUrlLogoutSuccessHandler来实现。但仍无法找到方法。那么这里可能出现什么问题?
2 回答

湖上湖
TA贡献2003条经验 获得超2个赞
好吧,你需要实施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"/>
并执行如下:
public class RefererRedirectionAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler implements AuthenticationSuccessHandler { public RefererRedirectionAuthenticationSuccessHandler() { super(); setUseReferer(true); } }
添加回答
举报
0/150
提交
取消