This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Spring and the fly likes Redirect question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Redirect question" Watch "Redirect question" New topic

Redirect question

Gabriela Rios
Ranch Hand

Joined: Feb 27, 2008
Posts: 32

I have a question regarding redirect. I have noticed that when I do a redirect some (NOT ALL) of my model attributes are passed in the URL. I can't quite understand why. I have some attributes that I want to maintain throughout my controllers so I added the annotation @SessionAttributes with the name of the model attributes. In all my controllers, I use at least two of those session attributes but I can only see this particular one always being passed. If I update one of those session attributes, it gets passed on the URL as well. The one that ALWAYS gets passed in my URL is a String. Other types of objects don't get passed in my URL. Is that the reason? If it's a string and/or if I just updated the attributes that is a string, will it get passed in my URL? I redirect using strings. I also use Apache Tiles.

Thanks in advance for the clarification.

Bill Gorder

Joined: Mar 07, 2010
Posts: 1648

By default all model attributes are considered to be exposed as URI template variables in the redirect URL. Of the remaining attributes those that are primitive types or collections/arrays of primitive types are automatically appended as query parameters.

Take a look at RedirectAttributes I commented on them a bit here

and here

You can find the java doc here:

Unlike other redirect attributes, which end up in the target redirect URL, flash attributes are saved in the HTTP session (and hence do not appear in the URL). The model of the controller serving the target redirect URL automatically receives these flash attributes after which they are removed from the session.

See more in the documentation here:

[How To Ask Questions][Read before you PM me]
jQuery in Action, 2nd edition
subject: Redirect question
Similar Threads
Passed with 95%
Passed scea 2 and 3