flybywire
flybywire

Reputation: 273972

spring mvc: parse repeated request param

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)

Upvotes: 3

Views: 2127

Answers (1)

James
James

Reputation: 1571

You can map it to an array like so

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

Upvotes: 5

Related Questions