Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What is the difference between spring mvc and spring dispatcherservlet?


Asked by Brooklyn Henry on Dec 12, 2021 Spring



As the name suggests, it's a module of the Spring framework dealing with the Model-View-Controller, or MVC pattern. It combines all the advantages of the MVC pattern with the convenience of Spring. Spring implements MVC with the front controller pattern using its DispatcherServlet.
Furthermore,
As I said, the DispatcherServlet is the backbone of Spring MVC and serves as the main controller which routes different HTTP request to corresponding Spring Controllers. It is an implementation of Front Controller design pattern and provides a single entry point to your Spring web application.
Moreover, spring-servlet.xml defines the beans that are related only to that servlet. Here it is the dispatcher servlet. So, your Spring MVC controllers must be defined in this file. There is nothing wrong in defining all the beans in the spring-servlet.xml if you are running only one servlet in your web application.
Similarly,
Spring MVC (Model–view–controller) is one component within the whole Spring Framework, to support development of web applications. Spring MVC is one component within the whole Spring Framework, to support development of web applications.
In respect to this,
Child Context The child-context in a Spring application is the ApplicationContext that is loaded by a DispatcherServlet (or for instance a MessageDispatcherServlet in a Spring-WS application). This context should only contain beans relevant to that context, for Spring MVC that would be ViewResolver s, HandlerMapping s etc.