나는 URI 아래의이 (가) 전달 된 CUSTOMER_ID에 대한 세부 정보를 가져 선택적 @PathVariable은 REST 컨트롤러 봄에 4
http://localhost:8080/customers/{customer_id}
- 다음 않습니다에 나머지 서비스 (HTTP 가져 오기 엔드 포인트), 쓰고 있어요 uri
- 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 봄 - 웹 4.3.10 버전
을 사용하고 있습니다.
당신은 개별 요청을 처리하기 위해 여기에 두 개의 엔드 포인트를 작성해야합니다
값 = { "/ customers", "customers/{customer_id}"})가 제안한 것과 같은 것을 찾고 있었는지는 개미 스타일입니다. –
감사합니다. @ByeBye .. 매력처럼 작동합니다. – technoJ
@technoJ는 답변을 수락하는 것을 잊지 않습니다. –