Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring Security 2.0.4 .... Redirect user to original page after authentication success or failure

 
Anoop Nair
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a web app which has a login form on all the pages.

I am using spring 2.5 .

After the login happens (whether successs or failure) the user should be redirected back to the same page. Can someone please tell me how to go about implementing this ?

Below are my files:

Spring XML file:


Authentication Class


Login form



The login form is present on all the pages and the user should be redirected to the page he was viewing after login success/failure.


 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This happens automatically. But I noticed you had default-target-url, which to me says after logging in send them to that page. If you remove it it should redirect them back to the page they tried to view, unless they enter invalid login stuff. which takes them to the general/home page

<security:form-login login-page="/loginURL"
login-processing-url="/loginURL"
authentication-failure-url="/general/home?login_error=true"
default-target-url="/general/home"/>

I would recheck the attributes to make sure they mean what you expect them to mean. I think you possibly just copied and pasted this from somewhere else expecting it to work correctly without understanding what it all meant.

Good Luck

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic