Is the DispatcherServlet instantiated via an application context?

Technology CommunityCategory: SpringIs the DispatcherServlet instantiated via an application context?
VietMX Staff asked 3 years ago

No, the DispatcherServlet is instantiated by Servlet containers like Tomcat or Jetty. You must define the DispatcherServlet into the web.xml file as shown below.

You can see that load-on-startup tag is 1, which means DispatcherServlet is instantiated when you deploy the Spring MVC application to Tomcat or any other Servlet container. During instantiation, it looks for a file servlet-name-context.xml and then initializes beans defined in this file.