0

I would like to batch search for entities like that:

GET api/stuff?ids=123+456+789+101112+...

I have found out that it is possible to get the request param like that:

@RequestMapping(method = RequestMethod.GET, value = "/stuff")
public String controllerMethod(@RequestParam Map<String, String> customQuery) {

    //After that I could get 123+456+789+101112+... and I could parse them.
    String ids = customQuery.get("ids");
}

Is there an alternative for the above solution which I could get the request param as a List, or any other solution?

GaborH
  • 689
  • 2
  • 11
  • 24

1 Answers1

0
@GetMapping("/stuff")
public String controllerMethod(@RequestParam("ids") List<Integer> ids) {

}

Then you should be able to call this as api/stuff?ids=123,456,789 or as api/stuff?ids=123&ids=456&ids=678

larsgrefer
  • 2,735
  • 19
  • 36