membersound
membersound

Reputation: 86757

How to accept mulitple REST query parameters with same id in spring-mvc?

How can I create a rest controller with spring-mvc that takes multiple parameters with the same name? localhost:8080/api?id=12&id=15&id=88

//pseudocode
@RestController
public class MyRest {
   @RequestMapping(method = RequestMethod.GET)
   public Object test(@RequestParam value="ids" required=false) List<Integer> ids) {
    Sysout(ids);
  }
}

Upvotes: 2

Views: 2521

Answers (1)

Predrag Maric
Predrag Maric

Reputation: 24433

?id=12&id=15&id=88 should work automatically with @RequestParam(value="id") List<Integer> ids

Upvotes: 7

Related Questions