に、私は以下のURIで、次のオプション@Pathvariable RESTコントローラバネ4
http://localhost:8080/customers/{customer_id}
- が渡さCUSTOMER_IDの詳細をフェッチん休息サービス(HTTPのGetエンドポイント)、書いています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);
}
しかしながら、上記のコードと、第2のシナリオ制御用)(getCustomersに流れています。
注:私は非常にこの上の任意の助けに感謝Java8と春-ウェブ4.3.10バージョン
を使用しています。
あなたは、個々のリクエスト処理するために、ここでは2つのエンドポイントを作成する必要があります
value = {"/ customers"、 "customers/{customer_id}"})です。 –
ありがとう@ByeBye ..魅力的な作品。 – technoJ
@technoJは答えを受け入れることを忘れないでください。 –