I'm trying to redirect the user back to the page where they clicked the login link. (Pages are read-only for non-authenticated users, but writable for logged in users.) How do I redirect the user back to where they came from after they login?
I'm sending to the user to the login page with this link: /spring_security_login?redirect=/item5
. After loging in, I expect the user to be redirected to /item5
page. However, they're always redirected to /
page.
Here is the configuration I'm using:
<http use-expressions="true">
<intercept-url pattern="/**" access="permitAll" />
<form-login authentication-success-handler-ref="simpleUrlAuthenticationSuccessHandler"/>
</http>
<beans:bean id="simpleUrlAuthenticationSuccessHandler"
class="org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler">
<beans:property name="defaultTargetUrl" value="/"/>
<beans:property name="targetUrlParameter" value="redirect"/>
</beans:bean>
It seems that targetUrlParameter
is not getting picked up as expected. I'm using Spring Security 3.1.4
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…