Spring MVC – Redirect to URL after login

Fortunately, Spring Security has built-in functionality for remembering the URL that was originally requested, and redirecting your users there after they successfully login. The quick answer to your question is that you need to enable this functionality by setting the always-use-default-target option to false in your Spring Security configuration.

For example, here’s a common line from the Spring Security config:

<form-login
login-page="/login.html"
authentication-failure-url="/login.html?status=LOGIN_FAILURE"
default-target-url="/secure/index.html"
always-use-default-target="false />
Advertisements
This entry was posted in Java, Programming. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s