用java下载文档的时候设置response的几种方式
//response信息的设置
response.reset();
response.setContentType("application/pdf");
//导出PDF名称
String fileName = "客户数据分析结果报表";
//inline为在线打开
response.setHeader("Content-Disposition", "inline; filename=\""
+ new String(fileName.getBytes("gb18030"), "ISO8859-1") + ".pdf" + "\"");
response.setContentLength(ba.size());
点击会提供对话框选择另存为:
response.setHeader("Content-Disposition", "attachment; filename=\"+filename);
通过
IE浏览器直接选择相关应用程序插件打开:
response.setHeader("Content-Disposition", "inline; filename=\"+filename);
下载前询问(是打开文件还是保存到计算机)
response.setHeader("Content-Disposition", "inline; filename=\"+filename);
小宝制造。