【发布时间】:2017-05-17 10:01:38
【问题描述】:
谁能告诉我如何从简单的终端客户端调用发布请求?
@POST
@Path("insertt")
public void insert(@QueryParam("id") Integer id,
@QueryParam("name") String name,
@QueryParam("lastname") String lastname,
@QueryParam("adress") String adress,
@QueryParam("city") String city ) {
Customer cust = new Customer();
cust.setCustomerId(id);
cust.setName(name);
cust.setLastNAme(lastname);
cust.setAddressline1(adress);
cust.setCity(city);
customerDAO.add( cust );
}
在客户端我做:
Client c = ClientBuilder.newClient();
WebTarget resource = c.target("http://localhost:8080/WebService/webresources/generic/insertt?id=100&name=test&lastname=test&adress=test&city=test");
//resource.request().post(); // This does not work
【问题讨论】:
-
什么不起作用?您看到了哪个例外?
-
你试过 curl 命令吗?
-
@MaximDobryakov 我没有看到任何异常我只是不知道如何从客户端发送请求。我有 url 和资源,但是如何从客户端发送请求?
标签: java rest jersey-2.0 jersey-client