008 @RequestMapping

Source: Internet
Author: User

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

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.