-1
我真的试图通过球衣客户端请求的Web服务:Jersey客户端请求的Web服务
WebResource service = client.resource(UriBuilder.fromUri("http://localhost:8080/jersey-example-new/").build());
System.out.println(service.path("rs/").path("account/details/1").accept(MediaType.APPLICATION_JSON).get(String.class));
,但我得到:
GET http://localhost:8080/jersey-example-new/rs/account/details/1 returned a response status of 406 Not Acceptable
请注意,URL路径http://localhost:8080/jersey-example-new/rs/account/details/1
作品在浏览器中。 Java客户端请求有什么问题?
端点代码:
@Path("account")
public class AccountDetailsService {
@GET
@Path("/details/{param}")
@Produces(MediaType.TEXT_PLAIN)
public Response getAccountDetails(@PathParam("param") String accountName) {
String output = "Account Name : " + accountName;
return Response.status(200).entity(output).build();
}
}
这就是说,作为回应返回的数据不在'MediaType.APPLICATION_JSON'中。检查你的方法生成的输出。 – Parth
显示您的端点方法的代码。 –
@CássioMazzochiMolin看到问题 – andy007