1::前端传数组参数用ids,不要用ids[],因为是传数组会自动加上[]
@ApiOperation(value = "批量删除", notes = "批量删除")
@DeleteMapping(value = "/batchDelete")
public Result<?> delete(@RequestParam(name = "ids[]", required = true) ArrayList<Integer> ids) {
sysStudyTestFileService.removeBatchByIds(ids);
return Result.ok("删除成功");
}
2:使用postman传数组有三种方法
2-1:方法一,后端使用@RequestParam接收传参
@ApiOperation(value = "批量删除", notes = "批量删除")
@DeleteMapping(value = "/batchDelete")
public Result<?> delete(@RequestParam(name = "ids[]", required = true) ArrayList<Integer> ids) {
sysStudyTestFileService.removeBatchByIds(ids);
return Result.ok("删除成功");
}
2-2:方法二,后端使用@RequestParam接受收传参
与@RequestBody不同,@RequestParam传递的数组中有多少个值,便排排下来写便是
(注意微操,参数名需为key的名称为@RequestParam括号里的名称,而不是定义的数组名)
@ApiOperation(value = "批量删除", notes = "批量删除")
@DeleteMapping(value = "/batchDelete")
public Result<?> delete(@RequestParam(name = "ids[]", required = true) ArrayList<Integer> ids) {
sysStudyTestFileService.removeBatchByIds(ids);
return Result.ok("删除成功");
}
文章来源:https://www.toymoban.com/news/detail-590517.html
2-3:方法三,后端使用@RequestBody接受收传参
@ApiOperation(value = "批量删除", notes = "批量删除")
@DeleteMapping(value = "/batchDelete")
public Result<?> delete(@RequestBody ArrayList<Integer> ids) {
sysStudyTestFileService.removeBatchByIds(ids);
return Result.ok("删除成功");
}
文章来源地址https://www.toymoban.com/news/detail-590517.html
到了这里,关于springboot后端接收前端传数组参数方法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!