http post提交数组

方式一:@RequestParam方式
服务提供方用@RequestParam注解接收参数,参数类型为long数组:

@ApiOperation(value = "***", tags = "***", notes = "***", response = ***)
@RequestMapping(value = "delivery", method = RequestMethod.POST)
public Object convert(
@RequestParam(value = "id", required = true) @ApiParam(value = "id数组", required = true) long[] id) {
return userService.convert(id);
}

服务调用方拼接多个id参数请求服务:
http://**/delivery?id=1&id=2
方式二:@RequestBody方式
服务提供方用@RequestBody注解接收参数,参数类型为long数组:

@ApiOperation(value = "***", tags = "***", notes = "***", response = ***)
@RequestMapping(value = "/delivery", method = RequestMethod.POST)
public Object delivery(@RequestBody long[] id) {
return userService.delivery(id);
}

服务调用方把数组放在body中,已application/json方式提交,postman示例如下:
application/json

原文地址:https://www.cnblogs.com/jpfss/p/9082777.html