Get input parameter annotations using the Spring controller

Source: Internet
Author: User


1. Parameters for handling the URI portion of the request: @PathVariable.

2. Handle the parameters of the request header section: @RequestHeader, @CookieValue
@RequestHeader annotations, you can bind the value of the header portion of a request to a method parameter.
@CookieValue can bind the value of the cookie in the request header to the parameters of the method.

[Email protected] annotations are used to receive the parameters in the address, and the format of the parameter is http://*****?uid=111111&uname= Zhang San.

[Email protected] annotations are used to receive parameters from the body of the request, @RequestBody can put multiple parameters into an entity class or map.


5. Parameter Validation @valid, @Validated
@Valid is used when using hibernate validation
@Validated is used only with the spring Validator check mechanism, @Validated is a single package of @valid and is used by the spring-provided checksum mechanism. @Valid does not provide grouping functionality
@Validated annotations can use a model to receive the parameters in the Address bar, and the format of the parameter is http://*****?uid=111111&uname= Zhang San.

To sort a group @GroupSequence annotations

Attention:
The A.bindingresult object must be next to the @Valid or @validated, otherwise it cannot receive the error message.
B. Multiple validation result objects are added when working with multiple model objects on a single functional method

Usage scenarios such as:
Spring MVC + @Valid/@Validated + @RequestBody receive JSON to verify JavaBean data validity

Get input parameter annotations using the Spring controller

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.