Binding a list in @RequestParam
Subscribing what basil said in a comment to the question itself, if method = RequestMethod.GET
you can use @RequestParam List<String> groupVal
.
Then calling the service with the list of params is as simple as:
API_URL?groupVal=kkk,ccc,mmm
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.
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 :)