@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Response
{
@XmlElement
private List<Customer> customers = new ArrayList<Customer>();
public Response(List<Customer> customers)
{
this.customers = customers;
}
public getCustomers()
{
return customers;
}
}
解组
javax.xml.bind.JAXB.unmarshal(source, Response.class);
source
任何输入流(文件、流) 在哪里
@GET
@Path("all")
@Produces({"application/xml", "application/json"})
public Response findAll() {
return new Response(getJpaController().findCustomerEntities());
}