Umesh Awasthi
Umesh Awasthi

Reputation: 23587

Redirecting user to same location where he came from in Spring MVC

I am trying to implement a functionality so that user after a successful Login should get redirected to same location from where he/she click the Login button.

I am using Spring MVC and for Login in some cases platform is using Spring security and for some third party Login process we are using out own mechanism.

I am wondering, is there any feature either in Spring MVC or Spring Security so that we can redirect user to same location from where he/she came.

Upvotes: 1

Views: 379

Answers (2)

Japan Trivedi
Japan Trivedi

Reputation: 4483

I agree with what @jittakal has answered. I have also used the SavedRequestAwareAuthenticationSuccessHandler class to redirect to the same view from where user was redirected to the login page.

It is really very easy and awesome feature to use. Go for it. :)

Upvotes: 0

jittakal
jittakal

Reputation: 919

Spring Security has provision to redirect the target URL

Have a look SavedRequestAwareAuthenticationSuccessHandler There are four scenarios based on which ss decides on the redirect destination.

Upvotes: 2

Related Questions