java - 使用 REST 服务下载文件列表
问题描述
我是 Java 新手,目前正在尝试下载文件列表。我将此代码作为下载单个文件的基础,它正在工作。
package com.java2novice.restful;
import java.io.File;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
@Path("/download")
public class RestDownloadService {
@GET
@Path("/service-record")
@Produces("application/pdf")
public Response getFile() {
File file = new File("C:\java2novice\employee_1415.pdf");
ResponseBuilder response = Response.ok((Object) file);
response.header("Content-Disposition",
"attachment; filename=\"employee_1415.pdf\"");
return response.build();
}
}
有人可以告诉我如何修改此代码,以便我能够下载文件列表吗?
解决方案
推荐阅读
- r - 删除最后一个空格之前的所有内容
- c++ - 编写一个包含两个类数据成员 numBorn 和 numliving 的类
- php - 用PHP中的链接替换文本
- java - 等到图像下载 Firebase
- hibernate - 使用 NamedEntityGraph
- java - 在 SharedPreference 中保存应用程序范围的布尔值
- odoo-8 - 清理 Many2one 字段
- mysql - dplyr 使用变音符号加入 Mysql 数据
- android - Web Speech API 适用于 Chrome,但在 ionic 应用程序中不适用。有什么区别以及哪些更改可以使其在 ionic 1 应用程序上运行?
- angular - 在 Angular v2-6 中内置 forEach 实用程序,就像在 AnularJS 中一样