File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirect question

 
Gabriela Rios
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

http://www.coderanch.com/t/571197/Spring/pass-cookies-java-spring#2601860

and here

http://www.coderanch.com/t/590033/Spring/return-ModelAndView-redirect#2687064

You can find the java doc here:
http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/web/servlet/mvc/support/RedirectAttributes.html

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:
http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#mvc-flash-attributes

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic