使用AngularJS从JAX-RS下载csv文件
我在客户端使用Angular JS,在服务器端使用Jax Rs。我从csv文件的服务器端发送路径。 如何从客户端下载 我的路径从服务器端发送 这应该行得通使用AngularJS从JAX-RS下载csv文件,angularjs,csv,download,jax-rs,Angularjs,Csv,Download,Jax Rs,我在客户端使用Angular JS,在服务器端使用Jax Rs。我从csv文件的服务器端发送路径。 如何从客户端下载 我的路径从服务器端发送 这应该行得通 @Path("/file") public class FileService { private static final String FILE_PATH = "c:\\file.csv"; @GET @Path("/get") @Produces("text/csv") public Resp
@Path("/file")
public class FileService {
private static final String FILE_PATH = "c:\\file.csv";
@GET
@Path("/get")
@Produces("text/csv")
public Response getFile() {
File file = new File(FILE_PATH);
ResponseBuilder response = Response.ok((Object) file);
response.header("Content-Disposition",
"attachment; filename=\"file_from_server.csv\"");
return response.build();
}
}