SPRINGMVC requestmappinghandlermapping Initialization detailed

Source: Internet
Author: User

SPRINGMVC Configure this tab to register three beans by default:requestmappinghandlermapping,requestmappinghandleradapter, Defaulthandlerexceptionresolver

Requestmappinghandlermapping

We see that it implements the Initializingbean interface, so when Getbean () instantiates it, it executes the Afterpropertiesset () method to see what the method is doing.

A builderconfiguration object is instantiated in the method, and some path crawlers, path method matches, and so on are set up for the object. Finally, you need to call the parent class's method

The parent class simply calls the Inithandlermethods () method, which is critical to match the request path and method

Get all the Beanname

Traverse all beanname and get type

Determines whether the class is @controller or @requestmapping annotated, is the execution Detecthandlermethods (beanname) method

First get the type class, according to class to get a map, the key of this map is Method,value is requestmappinginfo, after the article

Traverse map, get method and Requestmappinginfo, register them. The following article is detailed

Book before the article #

In the Selectmethods () method, all methods are obtained according to class classes, and the traversal method executes the Dowith method

Get methods and Requestmappinginfo, save them in a map and return, how didrequestmappinginfo get it? We'll see.

Executes the Getmappingformethod (method, Usertype) method in the Detecthandlermethods () method, which is an abstract method. requestmappinghandlermapping Execution method

Create the requestmappinginfoof the method, the following article #1-1

Create the requestmappinginfoof the class, which is the same as the previous step

Combining the former two, the following article is detailed #1-2

The book #1-1 before the text

Get information on the @requestmapping annotations on the method, create the requestmappinginfo according to the annotations

With the builder pattern created here, let's see what the Build () method did.

The key in the method is the patternsrequestcondition object, which holds the path value of the method annotation, such as/app, that creates the Requestmappinginfo returned by the object's Patterns property.

The book #1-2 before the text

method, and then re-create a return, let's take a look at the patternsrequestcondition method

The antpathmatcher object is used in conjunction with the class annotation path and the method annotation path, and if there are no wildcard characters, simple stitching such as/person,/list--and/person/list

Re-create a return

Book before the article #

Registering with the Mappingregistry Property object in abstracthandlermethodmapping

Create a Handlermethod object, followed by a detailed #2-1

Save the map and the corresponding method.

Get the mapping path and save the mapping path and the mapped object. After the article detailed #2-2

Get the name of the Requestmappinginfo and save the name and method.

Save the mapped object and the mapped registration object.

The book #2-1 before the text

Handlermethod , there are BEANNAME,BEANFACTORY,METHOD,METHODParameter

The book #2-2 before the text

Get the Patterns property value in patternsrequestcondition in requestmappinginfo

At this point, the initialization of requestmappinghandlermapping is complete.

SPRINGMVC requestmappinghandlermapping Initialization detailed

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.