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