Spring MVC Execution (Request-to-response) process

Source: Internet
Author: User

* Daily: * There are two choices before you get up every day, either keep on getting down and do your unfinished dreams or get up and finish your unfinished dreams.

-----**

-----

    The
    1. user wants the server hairstyle request to be intercepted by spring's front-end controller Dispatcherservlet. The
    2. Dispatcherservlet parses the request URL (Uniform Resource Locator) to get the URI (Request resource Identifier). Then, based on the URI, call handlermapping to get all the related objects of the handler configuration, including the handler object and the interceptor corresponding to the handler object. These objects are encapsulated in a Handlerexecutionchain object that is returned.
    3. Dispatcherservlet Select an appropriate handleradapter based on the handler obtained. Handleradapter's design conforms to the single-object-oriented principle of responsibility, the code structure is clear, easy to maintain, and most importantly, the code is reusable. Handleradapter will be used to handle a variety of handler, calling handler the method that actually handles the request. The
    4. extracts the model data from the request and begins execution of the handler (Controller). In the process of populating the handler, spring will do some extra work, depending on the configuration.
      (1) message translation. Converts a request message (such as data such as Json,xml) into an object, converting the object to the specified response information.
      (2) data conversion. Data conversions for request messages, such as string conversion to Integer, double, and so on. The
      (3) data is formatted. Data is formatted for the request message, such as converting a string to a formatted number or a grid
      type date, and so on.
      (4) data validation. Verify the validity of the data (length, format, etc.), and the validation results are stored in Bindingresult or error.
    5. Handler after execution completes, you want Dispatcherservlet to return a Modelandview object, and the Modelandview object should contain the view name and the model. The
    6. returns to Dispatcherservlet based on the returned Modelandview object, selecting an appropriate viewresolver (view resolver). The
    7. Viewresolver renders the view in combination with model and view. The
    8. returns the view render results to the client.

The above 8 steps, Dispatcherservlet, Handlermapping, Handleradapter, and Viewresolver, and other objects work together to complete the Spring MVC Request Response Workflow, The work done by these objects is not visible to the developer, and the developer does not need to be concerned about how these objects work, and the developer only needs to complete the business processing of the request within the handler (Controller).

Spring MVC Execution (Request-to-response) process

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.