Search code examples
springspring-mvcrequest-mapping

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?


Solution

  • 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