1 回答

TA貢獻1811條經驗 獲得超6個贊
我將代碼更改為:
@Path("/echo")
public class Echo {
@PUT
@Produces({MediaType.APPLICATION_JSON})
@Consumes(MediaType.TEXT_PLAIN)
@Path("/{name}/{family}")
public Response echoGet(
@PathParam("name") String name,
@PathParam("family") String family,
String Desc
) {
Map<String, Object> resp = new HashMap<>();
resp.put("success", "true");
resp.put("Name", name);
resp.put("Family", family);
resp.put("Desc", Desc);
Response.ResponseBuilder rb = Response.ok(resp,
MediaType.APPLICATION_JSON).status(Response.Status.OK);
return rb.build();
}
}
并像這樣將數據發送到 RESTFul API:
添加回答
舉報