SpringMVC that simply parse the source code

.

1.1 the init (initialization)
At the first request, it will call HttpServletBean the init () method

org.springframework.web.servlet.HttpServletBean.init () // read configuration files, initialization operation 
 org.springframework.web.servlet.FrameworkServlet.initServletBean () // initialize ServletBean 
  the this .webApplicationContext initWebApplicationContext = (); // Initial context 
   org.springframework.web.servlet.DispatcherServlet.onRefresh (WAC); // refresh context, including the initialization strategies 
    initStrategies (context); // initialize each policy 
     initMultipartResolver (context);
     initLocaleResolver(context);
     initThemeResolver(context);
     initHandlerMappings(context);
     initHandlerAdapters(context);
     initHandlerExceptionResolvers(context);
     initRequestToViewNameTranslator(context);
     initViewResolvers(context);
     initFlashMapManager(context);
  initFrameworkServlet (); // initialize Servlet

1.2 requesting
org.springframework.web.servlet.FrameworkServlet.doGet () // issue the get request, take this method 
 the processRequest () // get and post requests go this way by the org.springframework.web.context.request.RequestContextHolder ThreadLocal member variables get the context information over the latest set of context information to the ThreadLocal in 
  doServise () // set a series of related requests SpringMVC parameters: request.setAttribute 
   org.springframework.web.servlet.DispatcherServlet.doDispatch () // DispatcherServlet core method, according to the request to acquire a corresponding controller, a request to make the distribution process, controller result obtained by mav process, and then continues to play back to the front end 
    HandlerExecutionChain mappedHandler the getHandler = (request) // Get the controller in accordance with a corresponding request (from Get the container through the IOC bean name), including blocking the like (here, the cross-domain processing) 
     org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler ()
      org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandlerExecutionChain () // obtained interceptor system, and returns the processor chain 
      org.springframework.web.servlet.handler.AbstractHandlerMapping.getCorsHandlerExecutionChain () // first determine request header , then the interceptor to give cross-domain system 
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal () // processing request: the controller to 
     org.springframework.web.servlet.mvc.method.annotation .RequestMappingHandlerAdapter.handleInternal () // processing request: the Controller to 
      org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle () // to the Controller processes the request and obtain parameters
      org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue () // processing request parameter, if the parameter type of match type returned directly, where it will direct response

 

.

Guess you like

Origin www.cnblogs.com/lcmlyj/p/12340707.html