【发布时间】:2015-11-17 14:45:19
【问题描述】:
我正在尝试通过 jersey 客户端请求网络服务:
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中。检查生成输出的方法。 -
显示你的端点方法的代码。
-
@CássioMazzochiMolin 看到问题
标签: java web-services rest jersey jersey-client