SPRINGMVC Study Notes (4)-Front Controller

Source: Internet
Author: User

SPRINGMVC Study Notes (4)-Front Controller

    • SPRINGMVC Learning Note 4-Front Controller

In this paper, through the Front Controller source code Analysis SPRINGMVC execution Process

1. Front Controller receives request

Calling doDispatch methods

protectedvoiddoDispatchthrows Exception {        HttpServletRequest processedRequest = request;        null;        booleanfalse;         。。。。。}

2. Front-end controller call HandlerMapping (processor mapper) find handler based on URL

// Determine handler for the current request.mappedHandler = getHandler(processedRequest);
/** * Return The Handlerexecutionchain for this request.     * <p>tries All handler mappings in order. * @param Request current HTTP request * @return The Handlerexecutionchain, or {@code null} if no Han Dler could be found * /    protectedHandlerexecutionchainGetHandler(HttpServletRequest request)throwsException { for(Handlermapping HM: This. handlermappings) {if(Logger.istraceenabled ()) {Logger.trace ("Testing handler map ["+ HM +"] in Dispatcherservlet with Name '"+ getservletname () +"'"); } Handlerexecutionchain handler = Hm.gethandler (request);if(Handler! =NULL) {returnHandler }        }return NULL; }

3. Call the processor adapter to execute the handler and get the result of executionModelAndView mv

In the doDispatch method

// Actually invoke the handler.mv = ha.handle(processedRequest, response, mappedHandler.getHandler());

4. View rendering, populating the model data into the request domain

doDispatch, processDispatchResultrender

In the render method, the view is parsed to get view

// We need to resolve the view name.view = resolveViewName(mv.getViewName(), mv.getModelInternal(), locale, request);

Call the Render method of view to populate the request domain with the model data

In a render method, the View method that invokes the interface render

view.render(mv.getModelInternal(), request, response);

Program I also did not read, feeling analysis is relatively shallow, a lot of still did not understand, and so I system read the source code will tidy up a better.

Author @brianway More articles: personal website | CSDN | Oschina

SPRINGMVC Study Notes (4)-Front Controller

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.