Reputation: 1179
I am using @SessionAttribute in my Web Project. And I'm also using the @SessionScope. However I have no clear picture in what scenarios that we need to implement them and what differences they have? Yours Answers will be appreciated.
Upvotes: 0
Views: 1736
Reputation: 172
@SessionScope
gives hint to spring to create one instance of any @Component
for a single session. When a bean with this type of scope (using this annotation) is referenced then within a single session this instance is used repeatedly.
@SessionAttributes
is used basically for different purpose. Session attributes as indicated using this annotation correspond to a specific handler's model attributes, getting transparently stored in a conversational session. Those attributes will be removed once the handler indicates completion of its conversational session.
Upvotes: 1