可以
List<T>通过以下方式在响应中嵌入:
@Path("/stock")public class StockResource { @GET @Produces(MediaType.APPLICATION_JSON) public Response get() { Stock stock = new Stock(); stock.setQuantity(3); GenericEntity<List<Stock>> entity = new GenericEntity<List<Stock>>(Lists.newArrayList(stock)) {}; return Response.ok(entity).build(); }}客户必须使用以下行来获取
List<T>:
public List<Stock> getStockList() { WebResource resource = Client.create().resource(server.uri()); ClientResponse clientResponse = resource.path("stock") .type(MediaType.APPLICATION_JSON) .get(ClientResponse.class); return clientResponse.getEntity(new GenericType<List<Stock>>() { });}


