[SpringMVC source code analysis] How DispatchServlet is registered into the servlet container

When we use springboot automatic configuration, the process is as follows:

1. Register a DispatcherServletRegistrationBean class in the DispatchServletAutoConfiguration automatic configuration class

2. This DispatcherServletRegistrationBean class implements the ServletContextInitializer interface. This interface has only one onStartup method. After tomcat executes the start method, the bean that implements the ServletContextInitializer interface will be called

3. The first is the onStartup method of RegistrationBean, which calls the register method

4. Continue to call the addRegistration method

5. Finally, the api (servletContext.addServlet();) method of the servlet container is called to register the DispatchServlet

Guess you like

Origin blog.csdn.net/sumengnan/article/details/113773669