【发布时间】:2023-03-05 13:27:02
【问题描述】:
您好,我已经编写了一个 Rest Service 来接受 Long 值列表作为通过 RequestBody 的输入,下面给出了相同的代码:
@DeleteMapping("/files")
public ResponseEntity<?> deletefiles(@RequestBody List<Long> ids) {
fileService.deleteSelectedfiles(ids);
return ResponseEntity.ok().build();
}
当我尝试从 Postman 访问上述网址时,我收到以下错误:
"JSON parse error: Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: [![enter image description here][1]][1]Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token\n at [Source: (PushbackInputStream); line: 1, column: 1]"
在 Postman 中,我以以下格式将数据作为原始数据发送
{"ids": [1 ,2]}
谁能帮我解决这个问题
【问题讨论】:
-
您的请求正文不是数字数组。
-
粘贴你的js代码函数
标签: java json rest spring-boot postman