Meaning of "params" in @RequestMapping annotation?

CuriousMind picture CuriousMind · Aug 23, 2016 · Viewed 9.4k times · Source

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?

Answer

Codo picture Codo · Aug 23, 2016

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