我已经用一些webmethods构建了一个REST webservice。 但我没有得到它的工作传递参数到这些方法。REST传递参数与Java
I.E.
@GET
@Path("hello")
@Produces(MediaType.TEXT_PLAIN)
public String hello(String firstName, String lastName){
return "Hello " + firstname + " " + lastname
}
我该如何调用该方法以及如何传递参数firstname和lastname? 我试过这样的:
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource service = client.resource(getBaseURI());
ClientResponse response = service.path("hello")
.accept(MediaType.TEXT_PLAIN).put(ClientResponse.class);
但我在哪里添加参数?
感谢你的帮助, 最好的问候, 克里斯
谢谢你帮了我很多。但是如果我的方法想要一个字符串数组呢? – Chris 2012-03-28 11:54:51
@Chris:这应该有所帮助:http://stackoverflow.com/questions/5484209/pass-array-as-a-parameter-in-restful-webservice – npinti 2012-03-28 11:56:09
非常感谢。该链接也有助于您的最后一个链接的上下文:http://stackoverflow.com/questions/5718575/how-can-i-grab-all-query-parameters-in-jersey-jaxrs – Chris 2012-03-28 12:11:18