JAX-RS之下载文件
今天学习两个,分别是JAX-RS之下载文件
首先,看例子,下载服务器的文本文件
@Path("/file")public class FileService { private static final String FILE_PATH = "c:\\file.log"; @GET@Path("/get")@Produces("text/plain")public Response getFile() { File file = new File(FILE_PATH); ResponseBuilder response = Response.ok((Object) file);response.header("Content-Disposition","attachment; filename="file_from_server.log"");return response.build(); }