I. Overview
As we said before, the implementation class of the Handlermapping interface can help us map the URL to a controller method,
In the SPRINGMVC annotation driver, we can use @requestmaspping to complete.
II. structure of [email protected]
@Target ({elementtype.method, elementtype.type}) //The annotation can be tagged @Retention (retentionpolicy.runtime) above the method and class @Documented @mapping Public@interface requestmapping {String name ()default ""; Value and Path are an alias@AliasFor ("Path") string[] Value ()default {}; @AliasFor ("value") string[] path ()default {}; Methods for restricting requestsrequestmethod[] Method ()default {}; Restricting the parameters of a requeststring[]params()default {}; Limit Request Headersstring[] Headers ()default {}; Limiting the consumption of what MIMEstring[] Consumes ()default {}; What kind of Mimie are available ?string[] produces ()default {};}
From the structure of the annotation, we can see that. This annotation almost completes all of the URL mapping functionality.
Let's take a look at these features.
Three. Deepen
We typically add @requestmapping annotations on the processor class to complete a namespace.
[1] The method property is used to complete the limit of the request methods.
The parameter used is the Requestmethod enumeration object.
[2] Restrictions on request parameters
We're hardly going to use this.
[3] Restrictions on the request header
This is hardly going to be used in our reality.
[4] Limiting the MIME type of consumption, we would hardly go to use
[5] Limiting the MIME type of the response
This is more important, we put it in the following directions.
008 @RequestMapping