【发布时间】:2024-05-22 22:35:01
【问题描述】:
我的要求是从 ids 列表中获取实体列表,我正在尝试这样的事情,当我使用字符串方法时,我正在获取列表,但是当我尝试返回它时,它说不是找到了。
我的回购代码
List<AddingProductForView> findAllByproductidIn(ArrayList<Integer> productid);
我的服务代码:-
public List<AddingProductForView> getListOfData(ArrayList<Integer> productid){
List<AddingProductForView> findAllByProductIdIn = repository.findAllByproductidIn(productid);
return findAllByProductIdIn;
}
我的控制器代码:-
@PostMapping("/getProductsId")
public List<AddingProductForView> getListOfData(@RequestBody ArrayList<Integer> productid) {
List<AddingProductForView> findAllByProductIdIn = fileService.getListOfData(productid);
return findAllByProductIdIn;
}
在打印 toString 方法时(得到结果为:-
`[AddingProductForView [productid=1, productname=RO, imagepath=./assets/1.jpeg, price=4000 , productdescription=best], AddingProductForView [productid=2, productname=RO, imagepath=./assets/2.jpeg, price=8000 , productdescription=cheap], AddingProductForView [productid=3, productname=RO, imagepath=./assets/3.jpeg, price=2000 , productdescription=values]]`
我想从邮递员那里得到什么:-
[1,3,2]
错误:- { "时间戳": "2021-07-02T07:25:50.973+0000", “状态”:404, “错误”:“未找到”, "message": "没有可用的消息", “路径”:“/api/excel/getProductsId” }
【问题讨论】:
-
这里的实际问题是什么?
-
questionUpdated@rkosegi
-
尝试将 {"productId":[1,2,3]} 放在邮递员请求正文中,您应该告诉我们您的问题是什么,以及您想做什么@DivyeshKumar
-
badRequest , QuestionUpdated @Dolphin
-
试着把我告诉邮递员的东西@DivyeshKumar
标签: java spring spring-boot spring-mvc spring-data