If i write a simple servlet application, in my servlet class i extend the http servlet. This lets the container know that my class is a servlet and it will manage the \'life
But will this spring controller class be 'mananged' by the container in a same way a servlet lifecyle is managed?
Not directly. Then entry point of a Spring MVC application is typically a DispatcherServlet*. This class extends (not directly, but through inheritance) HttpServlet
. You declare it as you would any other Servlet
, typically in web.xml
.
However you don't declare it by itself. You provide a Spring ApplicationContext
from which the DispatcherServlet
can go and get the @Controller
annotated classes it will use to handle requests.
The DispatcherServlet
handler stack is pretty big. There are many components involved. The official Spring MVC is an excellent document. You should read it.
*I say typically because Spring provides other handlers, HttpRequestHandler
for example.
Additional Reading: