Use the @RequestParam annotation to bind request parameters to a method parameter in your controller.
AFAIK, request parameters are variables retrieved from query strings if the request method is GET. They are also the variables retrieved from the form values when the request method is POST. I've verified this using a simple JSP that displays request parameters through method request.getParameter("key")
.
But it seems to me that @RequestParam
only works on GET method requests. It can only get values from query strings.
Is this a bug in the documentation? Can someone please cite me some documentation that describes exactly what @RequestParam
is used for, what it cannot be used for, and how it gets populated?
Can I use @RequestParam
for POST methods to get the form values? If I can't use @RequestParam
, what else can I use? I'm trying to avoid calling request.getParameter("key")
.