【发布时间】:2010-11-09 14:28:41
【问题描述】:
我正在使用 Netbeans 创建一个小型 REST Web 服务。这是我的代码:
private UriInfo context;
private String name;
public GenericResource() {
}
@GET
@Produces("text/html")
public String getHtml() {
//TODO return proper representation object
return "Hello "+ name;
}
@PUT
@Consumes("text/html")
public void putHtml(String name) {
this.name = name;
}
我调用 get 方法没问题,因为当我调用 http://localhost:8080/RestWebApp/resources/greeting 时,我得到“Hello null”,但我正在尝试使用 http://localhost:8080/RestWebApp/resources/greeting?name=Krt_Malta 传递参数,但没有调用 PUT 方法......这是传递参数的正确方法还是我遗漏了什么?
我是 Rest bdw 的新手,如果这是一个简单的问题,请原谅。
谢谢! :) Krt_马耳他
【问题讨论】:
-
你用什么来调用 URL?你试过 curl -X PUT http://...?