java如何将头信息作为键值对传递给使用jersey的rest服务
我得到了一个web服务的url,它以json格式返回值,但它需要get请求中的头信息作为键值对,例如,我需要将Emp_代码作为键传递,“xyz”作为值来获取postman中所有员工的详细信息。下面是我试过的代码
private static void getEmployees()
{
final Client client = new Client();
final WebResource webResource = client.resource("http://abc/springrestexample/employees");
final ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);
if (response.getStatus() != 200)
{
throw new RuntimeException("Failed Http Error code " + response.getStatus());
}
final String output = response.getEntity(String.class);
System.out.println("Output from Server .... \n");
System.out.println(output);
}
在上面的代码中,我应该如何传递标题信息(键值)以获得所需的结果
# 1 楼答案
你可以加上。接受后的标题(“键”、“值”)。请在下面查看