Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JPA、REST、解组元素列表_Java_Rest_Jaxb_Jax Rs - Fatal编程技术网

Java JPA、REST、解组元素列表

Java JPA、REST、解组元素列表,java,rest,jaxb,jax-rs,Java,Rest,Jaxb,Jax Rs,我的REST服务中有一个GET函数,它以XML格式返回对象列表 @GET @Path("all") @Produces({"application/xml", "application/json"}) public List<Customer> findAll() { return getJpaController().findCustomerEntities(); } @GET @路径(“全部”) @产生({“application/xml”、“application/j

我的REST服务中有一个GET函数,它以XML格式返回对象列表

@GET
@Path("all")
@Produces({"application/xml", "application/json"})
public List<Customer> findAll() {
    return getJpaController().findCustomerEntities();
}
@GET
@路径(“全部”)
@产生({“application/xml”、“application/json”})
公共列表findAll(){
返回getJpaController().findCustomerEntities();
}
如何将XML列表解组到对象列表? 我想将数据库中的所有这些客户存储到客户对象的一些列表或向量中

@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;
   }
} 
其中
source
是任何输入流(文件、流)

其中
source
是任何输入流(文件、流)


可能重复的可能重复似乎有效,但我不知道为什么我的列表总是空的。似乎有效,但我不知道为什么我的列表总是空的。
javax.xml.bind.JAXB.unmarshal(source, Response.class);  
@GET
@Path("all")
@Produces({"application/xml", "application/json"})
public Response findAll() {
    return new Response(getJpaController().findCustomerEntities());
}