In this image (which I got from here), HTTP request sends something to Dispatcher Servlet.
We can say like DispatcherServlet
taking care of everything in Spring MVC.
At web container start up:
DispatcherServlet
will be loaded and initialized by calling
init()
methodinit()
of DispatcherServlet
will try to identify the Spring
Configuration Document with naming conventions like
"servlet_name-servlet.xml"
then all beans can be identified.Example:
public class DispatcherServlet extends HttpServlet {
ApplicationContext ctx = null;
public void init(ServletConfig cfg){
// 1. try to get the spring configuration document with default naming conventions
String xml = "servlet_name" + "-servlet.xml";
//if it was found then creates the ApplicationContext object
ctx = new XmlWebApplicationContext(xml);
}
...
}
So, in generally DispatcherServlet
capture request URI and hand over to HandlerMapping
. HandlerMapping
search mapping bean with method of controller, where controller returning logical name(view). Then this logical name is send to DispatcherServlet
by HandlerMapping
. Then DispatcherServlet
tell ViewResolver
to give full location of view by appending prefix and suffix, then DispatcherServlet
give view to the client.