When I want a model in Session scope in Spring 3, I use the foll. annotation in a Controller:-
@SessionAttribute("myModel");
However, this is just the declaration of myModel. At which point does it gets initialized so that I use it in a View. And how will Spring know the class-type of this model?
Can someone explain this with example?
@SessionAttributeworks as follows:@SessionAttributeis initialized when you put the corresponding attribute into model (either explicitly or using@ModelAttribute-annotated method).@SessionAttributeis updated by the data from HTTP parameters when controller method with the corresponding model attribute in its signature is invoked.@SessionAttributes are cleared when you callsetComplete()onSessionStatusobject passed into controller method as an argument.Example: