나는 일반적인 ServiceResponse 클래스가RESTEasy에서 일반 템플릿 (<T>)을 사용하여 클래스에서 XML 응답을 생성하는 방법은 무엇입니까?</p> 내 RESTEasy가 서비스에서 <pre><code>@XMLRootElement public class ServiceResponse<T> { private T data; private String error; //setters n getters } </code></pre> <p>, 난 같은 XML 응답 생성 할 : 다음과 같이
List<Customer> customers = someDAO.getCustomers();
ServiceResponse<List<Customer>> resp = new ServiceResponse<List<Customer>>();
resp.setData(customers);
resp.setError("No Error");
return resp;
or return Response.ok().entity(resp).build();
을하지만이 자바에 대한 JaxbMarshallWriter 없기 때문에 오류를 던지고있다 .util.List.
사용자 정의 GenericEntity 클래스를 marshalling 할 수 있습니다.
GenericEntity<List<Customer>> entity = new GenericEntity<List<Customer>>(customers){};
Response.ok(entity).build();
그러나 GenericEntity<ServiceResponse<List<Customer>>>
는 java.util.List에 대한 JaxbMarshallWriter 말을하지 작동하지 않습니다.
일반 템플릿 (,)을 사용하여 클래스를 마샬링/언 마샬링 할 수있는 방법이 있습니까?
아마도 도움이 될까요? http://stackoverflow.com/questions/5391486/make-a-collection-generic-in-javax-xml-bind – Friso