Assign the parameter with the specified name in the request to the formal parameter in the controller.
Attributes:
value: The name in the request parameter.
required: Whether this parameter must be provided in the request parameters. Default value: true. Indicates that it must be provided, if not provided, an error will be reported.
Used to obtain the content of the request body. Use directly to get data with key=value&key=value... structure.
The get request method is not applicable.
Attributes:
required: Whether there must be a request body. The default value is: true. When the value is true, the get request method will report an error. If the value is false, the get request is null.
Because the browser form only supports GET and POST requests, and DELETE, PUT and other methods do not support, Spring3.0 added a filter, you can change the browser request to the specified request method, and send it to our controller method , Making it support GET, POST, PUT and DELETE requests.
Instructions:
Step 1: Configure the filter in web.xml.
Step 2: The request method must use post request.
Step 3: Provide the _method request parameter as required. The value of this parameter is the request method we need.
37.8.5 RequestHeader
effect:
Used to get the request message header.
Attributes:
value: Provide the name of the message header
required: whether this message header must be present
Note:
It is generally not used much in actual development.
This annotation is newly added after SpringMVC4.3. It can be used to modify methods and parameters.
Appears on the method, which meansThe current method will be executed before the controller method is executed. It can modify methods that do not have a return value, or methods that have a specific return value.
Appears on the parameter,Get the specified data and assign values to the parameters。
Attributes:
value: The key used to obtain the data. The key can be the attribute name of the POJO or the key of the map structure.
Application scenarios:
When the form submission data is not complete entity data, ensure that the fields without submitted data use the original data of the database object.
E.g:
When we edit a user, the user has a creation information field, and the value of this field is not allowed to be modified. When submitting the form data, there must be no content of this field. Once updated, the content of this field will be set to null. At this time, you can use this annotation to solve the problem.
37.8.8 SessionAttribute
effect:
Used to execute parameter sharing between controller methods multiple times.
Attributes:
value: used to specify the name of the stored attribute