Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of "params" in @RequestMapping annotation?

I am aware of @RequestMapping annotation which is used in Spring MVC based application.

I came across this piece of code:

@RequestMapping(method = POST, params = {"someParam"})

I understood the method. However I don't know what params means? Before this I never had seen anything which passed params to this annotation.

Can anyone help in understanding this?

like image 735
CuriousMind Avatar asked Aug 23 '16 13:08

CuriousMind


People also ask

What is params in Spring?

In Spring MVC, the @RequestParam annotation is used to read the form data and bind it automatically to the parameter present in the provided method. So, it ignores the requirement of HttpServletRequest object to read the provided data.

What is params in Spring boot?

Spring @RequestParam @RequestParam is a Spring annotation used to bind a web request parameter to a method parameter. It has the following optional elements: defaultValue - used as a fallback when the request parameter is not provided or has an empty value. name - name of the request parameter to bind to.

What is the @RequestMapping annotation used for?

RequestMapping annotation is used to map web requests onto specific handler classes and/or handler methods. @RequestMapping can be applied to the controller class as well as methods.

Which of the following parameters can be configured using @RequestMapping?

To configure the mapping of web requests, we use the @RequestMapping annotation. The @RequestMapping annotation can be applied to class-level and/or method-level in a controller. The class-level annotation maps a specific request path or pattern onto a controller.


1 Answers

Your example means that the parameter someParam must be present in the request. This is used to narrow down the matching methods for the given request.

See the documentation: RequestMapping#params

like image 85
Codo Avatar answered Oct 09 '22 06:10

Codo