如何在 Spring 引导中搜索 multiply(batch) 参数?
How to search for multiply(batch) params in Spring boot?
我想批量搜索这样的实体:
GET api/stuff?ids=123+456+789+101112+...
我发现可以像这样获取请求参数:
@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");
}
上述解决方案是否有替代方案,我可以将请求参数作为列表或任何其他解决方案?
@GetMapping("/stuff")
public String controllerMethod(@RequestParam("ids") List<Integer> ids) {
}
那么您应该可以将其称为 api/stuff?ids=123,456,789
或 api/stuff?ids=123&ids=456&ids=678
我想批量搜索这样的实体:
GET api/stuff?ids=123+456+789+101112+...
我发现可以像这样获取请求参数:
@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");
}
上述解决方案是否有替代方案,我可以将请求参数作为列表或任何其他解决方案?
@GetMapping("/stuff")
public String controllerMethod(@RequestParam("ids") List<Integer> ids) {
}
那么您应该可以将其称为 api/stuff?ids=123,456,789
或 api/stuff?ids=123&ids=456&ids=678