Я пытаюсь отправить список методом GET.
Вот моя серверная часть:
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<User> getUsers(){
return managment.getUsers();
}
И моя клиентская сторона:
public static void getUsers(){
try {
ClientConfig clientConfig = new DefaultClientConfig();
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
Client client = Client.create(clientConfig);
WebResource webResource = client
.resource("http://localhost:8080/Serwer07/user");
ClientResponse response = webResource.accept("application/json")
.get(ClientResponse.class);
if (response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatus());
}
List users = response.getEntity(List.class);
User user = (User) users.get(0); //cannot cast
e.printStackTrace();
}
}
У меня проблема с приведением объекта Java к пользователю. Как я могу отправить этот список?
Заранее спасибо.