Som*_*yya 6 java rest jax-rs jersey
我正在尝试让REST服务从本地硬盘返回一个zip文件.以下就是我在做什么
@Path("/interface3/{Ent_id}/{esf_app_id}/{esf_app_ver}")
public class Interface3Mock {
// This method is called if TEXT_PLAIN is request
@GET
@Produces("application/zip")
public Response callInterface3_text(
@PathParam("Ent_id") Integer entitlement_id,
@PathParam("eapp_id") String eapp_id,
@PathParam("eapp_ver") String eapp_ver) {
File f = new File("D:\\Documentation\\Documentation.zip");
String mt = new MimetypesFileTypeMap().getContentType(f);
return Response.ok(f, mt).build();
}
}
Run Code Online (Sandbox Code Playgroud)
现在当我使用浏览器即.Internet Explorer和URL中的键http://localhost:9788/mockRESTServer/rest/interface3/123456/k123/l345
我看到一个文件下载对话框,上面写着"你想保存文件l345`.
我想让它问我的zip下载即.D:\\Documentation\\Documentation.zip.但不知何故,它占用了请求URL中的最后一个参数.
Mat*_*all 11
return Response.ok(f, mt)
.header("Content-Disposition", "attachment; filename=Documentation.zip")
.build();
Run Code Online (Sandbox Code Playgroud)
请参阅如何在JAX-RS中设置响应头,以便用户看到Excel的下载弹出窗口?
| 归档时间: |
|
| 查看次数: |
5742 次 |
| 最近记录: |