Home » Spring Framework » Spring MVC » Spring MVC Excel View Example. Spring MVC Excel View Example. By MemoryNotFound Published May 19, 2016 Updated May 19, 2016. Discover more articles. Download it – spring mvc excel view example.
I'm working with Spring 3 MVC (I'm quite new to it...) and I need some database info to be loaded after user's loggin and stay available until user logs out or closes the web page (I could query the DB each time I need it but it wouldn't be efficient).As far as I know, this should be done through session's management. I've found the following tutorial for managing session data:
Do you think this is a good starting point? Is the 3rd option mentioned the best approach for what I need?When am I supposed to populate the objects that I need to keep in the user's session? Is it OK to do it when the user logs in?
I was also wondering if it is possible to keep some information that should be common to all users (something like a session that is valid for each user).
Thank you very much!!
HauriHauri1 Answer
I don't think that link is a good starting point. it overly complicates things. There is often no need to change scope of beans, as recommended in the article. In fact having a controller instantiated per request is very inefficient. A new instance of an object would created for every single request - I literally can't think of a worse idea for a scalable performant website.
Spring security makes it easy. Just have a user object containing the relevant data that is returned by your implenetation of the user service.
There is no need to change scope of anything, keep it simple and use the default of singleton (will make scaling easier). And if really necessary use a session attribute.