簡體   English   中英

在url Restful服務中傳遞參數?

[英]Passing a parameter in url Restful service?

我正在使用Jersey RESTful Web服務。 我有下面的方法。

@PUT @Path("{id}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Wine update(Wine wine) {
    return dao.update(wine);
}

現在如何在這里提取{id}值? 我需要編號來更新酒。

另外,如何為上述方法編寫客戶端?

嘗試跟隨

@PUT @Path("{id}") 
 @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) 
 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 
 public Wine update(@PathParam("id") String id,Wine wine) {
     return dao.update(wine); 
 }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM