SpringMVC source code analysis and start the process

https://yq.aliyun.com/articles/707995

 

When Spring's web container will start to read the web.xmldocument, related to the startup sequence: <context-param> --> <listener> --> <filter> --> <servlet>specifically:

  • 1, to resolve <context-param>key-value pairs
  • 2, i.e. to create an application object ServletContext, servlet context for shared globally
  • 3, the <context-param>key-value pair into the ServletContext, web application global shared
  • 4, read the <listener>label, create a listener, general use ContextLoaderListener, if used ContextLoaderListener, Spring will create a WebApplicationContext objects, this is IOC容器ContextLoaderListenerto create IOC容器a globally shared, and place it ServletContextin key named WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTEto read web.xmlfile the contextConfigLocationconfiguration xml file to create the bean
  • 5, listener Once created if there is going to create Filter Filter
  • 6, initialization Servlet, generally used class DispatchServlet
  • 7, DispatchServlet FrameworkServlet will override the parent class method initServletBean parent class, and calls initWebApplicationContext()and onRefresh()methods
  • 8, initWebApplicationContext()the method creates a child of the current IOC a servlet container, if the presence of the above-described global WebApplicationContextthen provided parent container, without the presence of the global parent container is null.
  • 9, read <servlet>the label <init-param>configuration xml file and load-related Bean
  • 10. The onRefresh()method of creating Web applications related components

Guess you like

Origin www.cnblogs.com/zheng123/p/11456487.html