前端传数组,后端可用list接收,apifox对应用数据结构-array

发布时间 2023-05-08 14:35:23作者: CC&

一开始apifox的body设置如图

idea报错:
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type java.util.ArrayList<java.lang.Integer> from Object value (token JsonToken.START_OBJECT)]
修改apifox设置:

成功

controller层:

@PostMapping("/deleteProduct")
    public CommonResp deleteProduct(@RequestBody List<Integer> ids){
        return productService.deleteProduct(ids) ? CommonResp.success("删除成功"):CommonResp.failed("删除失败");
    }