https://yq.aliyun.com/articles/707995
When Spring's web container will start to read the web.xml
document, 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 useContextLoaderListener
, if usedContextLoaderListener
, Spring will create a WebApplicationContext objects, this isIOC容器
,ContextLoaderListener
to createIOC容器
a globally shared, and place itServletContext
in key namedWebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
to readweb.xml
file thecontextConfigLocation
configuration 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()
andonRefresh()
methods - 8,
initWebApplicationContext()
the method creates a child of the current IOC a servlet container, if the presence of the above-described globalWebApplicationContext
then 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