how to redirect user to the page before login screen
I am using Spring Security 3.2 to implement login screen.
When user clicks on login link, he is redirected to login page url. Now, after successful login, I want him redirect back to the page before login screen.
Is there any simple way to do that using Spring Security?
security-config.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
<http pattern="/resources" security="none" />
<!-- HTTP security configurations -->
<http auto-config="true" use-expressions="true">
<!-- Configure these elements to secure URIs in your application -->
<intercept-url pattern="/admin.htm" access="hasRole('ROLE_ADMIN')" />
<form-login login-processing-url="/j_spring_security_check"
login-page="/login.htm" authentication-failure-url="/login.htm?login_error=t" />
<remember-me key="myAppKey" token-validity-seconds="864000" />
<access-denied-handler error-page="/denied" />
</http>
<authentication-manager>
<authentication-provider user-service-ref="customUserDetailsService">
<password-encoder hash="sha" />
</authentication-provider>
</authentication-manager>
</beans:beans>