spring mvc: parse repeated request param

java, rest, spring, spring-mvc

Solution

You can map it to an array like so

public String getFile(@RequestParam(value="id") int[] ids){
    ...
}

Problem

As you probably know, http supports repeated parameters, such as `http://host/file?id=1&id=2`. In my case a Javascript element sends the ids of multiple rows in order for the server to do something with all these ids. Is it possible for Spring MVC to give me all the ids as a collection? (List or Array)

Original source

Related problems