我正在编写一个Rest服务(HTTP Get端点),以下uri执行以下操作:
http://localhost:8080/customers/{customer_id}
- 获取通过uri传递的customer_id的详细信息。
- 如果未传递customer_id(http://localhost:8080/customers),则获取所有客户的详细信息。
代码:
@RequestMapping(method = RequestMethod.GET, value = "customers/{customer_id}")
public List<Customer> getCustomers(
@PathVariable(name = "customer_id", required = false) final String customerId) {
LOGGER.debug("customer_id {} received for getCustomers request", customerId);
}
然而,对于上述代码,对于第二种情况,控制流正在流向getCustomers()。
注意:我正在使用Java8和spring-web 4.3.10版本。
非常感谢您的帮助。