[英]return list of file in java web rest service
我是 java rest web 服务的新手。 我正在编写一个 Web 服务方法来返回文件列表。我正在使用球衣。 但是我收到错误 500。我使用 GenericEntity 返回列表。 我被困在过去 2 天。 我在这里添加了代码。 请帮忙。
@GET
@Path("/getAttachmentsList")
@Produces(MediaType.APPLICATION_ATOM_XML)
public Response getAttachmentList(){
ArrayList<File> list=new ArrayList<File>();
for(int i=1;i<=6;i++){
File file = new File("C:/Users/name/Sample_"+i+".pdf");
list.add(file);
}
GenericEntity<ArrayList<File>> genericList=new GenericEntity<ArrayList<File>>(list){};
return Response.ok(genericList).build();
}
请检查您添加的 jar 文件。
如果继续使用application_atom_xml,一定要在pom.xml中添加jersey-atom依赖
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.