Binding a list in @RequestParam
Or you could just do it that way:
public String controllerMethod(@RequestParam(value="myParam[]") String[] myParams){ ....}
That works for example for forms like this:
<input type="checkbox" name="myParam[]" value="myVal1" /><input type="checkbox" name="myParam[]" value="myVal2" />
This is the simplest solution :)
Arrays in @RequestParam
are used for binding several parameters of the same name:
myparam=myValue1&myparam=myValue2&myparam=myValue3
If you need to bind @ModelAttribute
-style indexed parameters, I guess you need @ModelAttribute
anyway.
Just complementing what Donal Fellows said, you can use List with @RequestParam
public String controllerMethod(@RequestParam(value="myParam") List<ObjectToParse> myParam){....}
Hope it helps!