gpt4 book ai didi

java - 如何在GET请求中传递postman中的列表并进入GetMapping

转载 作者:行者123 更新时间:2023-11-30 06:08:10 32 4
gpt4 key购买 nike

我像这样使用 Postman 向 Controller 发送 id 列表

localhost:8090/test/customer?id=1,2

像这样的 Controller

@GetMapping
public List<Customer> getCustomerListById(Optional<List<Integer>> customerId){

return getCustomerByIdService.getCustomerById(customerId.get());

}

我的 CustomerRepo 像这样

public interface CustomerRepo extends CrudRepository<Customer , Integer>{

public List<Customer> findByCustomerIdIn(List<Integer> customerId);

}

但出现这样的错误

{
"timestamp": 1528884327211,
"status": 500,
"error": "Internal Server Error",
"exception": "java.util.NoSuchElementException",
"message": "No value present",
"path": "/test/customer"
}

最佳答案

在您的网址中,参数名称是 customer,但在您的 Controller 方法中,参数名称是 customerId,它们不相同

关于java - 如何在GET请求中传递postman中的列表并进入GetMapping,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50834526/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com