In SpringMVC load-on-startup tag role configuration DispatcherServlet

meaning

When servlet configuration, meaning <load-on-startup> tag is:
whether the mark is created when publishing objects DispatcherServlet web project and the init method,
when the value of 0 or greater than 0, represents a release web to load the items servlet performs inti method and
when a is negative or not specified, it indicates DispatcherServlet container loads created when the object performs the init method of the servlet is selected
smaller the value of a positive number, the higher priority start the servlet

effect

We begin with the init method: This method from the parent class HttpServletBean abstract class, the method mainly acquired name, and the specific configuration servlet path
i.e. <inti-param> parameters
Here Insert Picture Description
is then performed initServletBean () ;, which is derived from FrameworkServlet to abstract class, the key is to jump to initWebApplicationContext () method
Here Insert Picture Description

initWebApplicationContext (); This method is derived from the abstract class FrameworkServlet;

We can see this method creates WebApplicationContext objects wac, wac entire method is the initialization container (SpringMVC context)
refreshEventReceived global variable to false, the negation was true, after this judgment

Finally wac method was introduced to onRefresh
Here Insert Picture Description

DispatcherServlet onRefresh override the method passed in is passed directly to the container wac method initStrategies

Here the main initialize various strategies to achieve class interface

The general process is so initialized

Here Insert Picture Description

to sum up

  1. HttpServletBean main things that do some initialization, configuration parameter is set to web.xml servlet. For example the sub-label tag servlet init-param tag parameters;
  2. Spring FrameworkServlet the Servlet container associated with the context; attribute is initialized FarmeworkServlet WebApplicationContext, this property represents springmvc context, it has a parent context;
  3. DispatcherServlet implement various initialization functions such as exception handling, view processing, mapping function request;
Published 101 original articles · won praise 3 · Views 2237

Guess you like

Origin blog.csdn.net/S_Tian/article/details/104369506