I am new to Spring MVC and would like to know how it handles requests, more specifically:
- I would like to know how a Spring
@Controller’s life cycle relates to
that of a Servlet? - I would also like to better
understand what are the best
practices for multi-threaded
enviornments (e.g. like in Servlets,
are class attributes visible to
multiple HTTP requests as objects are
reused from the pool)?
A controller (as any spring bean) has a scope.
At best your controllers should be of scope
singleton. In that case it is very much like servlets, and:If your controller scope is
requestorsession, then you can have instance variables, and an instance of the controller is created on each new request/session.