Связывание списка в @RequestParam

I'm sending some parameters from a form in this way:

myparam[0]     : 'myValue1'
myparam[1]     : 'myValue2'
myparam[2]     : 'myValue3'
otherParam     : 'otherValue'
anotherParam   : 'anotherValue' 
...

I know I can get all the params in the controller method by adding a parameter like

public String controllerMethod(@RequestParam Map<String, String> params){
    ....
}

I want to bind the parameters myParam[] (not the other ones) to a list or array (anything that keeps the index order), so I've tried with a syntax like:

public String controllerMethod(@RequestParam(value="myParam") List<String> myParams){
    ....
}

and

public String controllerMethod(@RequestParam(value="myParam") String[] myParams){
    ....
}

but none of them are binding the myParams. Even when I add a value to the map it is not able to bind the params:

public String controllerMethod(@RequestParam(value="myParam") Map<String, String> params){
    ....
}

Is there any syntax to bind some params to a list or array without having to create an object as @ModelAttribute with a list attribute in it?

Thanks

116
задан Javi 4 January 2011 в 17:09
поделиться