簡體   English   中英

返回java web rest服務中的文件列表

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM