在页面上点击下载,弹出下载对话框,自定义选择路径,JAVA中如何获取绝对路径,
需要得到文件的绝对路径向里面写内容
类似:D:\\text
this.response.setContentType("application/vnd.ms-excel");
this.response.addHeader("Content-Disposition", "attachment; filename=" + new String("text".getBytes("GBK"), "ISO-8859-1"));
this.response.setCharacterEncoding("GBK");
this.writer = this.response.getWriter();
//向text.xls里写数据
writeExcel("D://text",colName,ds);
这里路径是写死的,保存后就放在D盘下了,现在是想通过弹出的保存对话框,选择路径和文件名,做为参数放进去
String path = application.getRealPath("/");
Map map = (Map)request.getAttribute("map");
String src = (String)map.get("zipSrc");
String filename = (String)map.get("zipName");
response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader( "Content-Disposition;charset=GBK ","attachment; filename=\"" + filename + "\"");
//File file = new File("D://五医院费用明细表.xls");
File file = new File(src);
FileInputStream in = new FileInputStream(file);
byte[] buffer = new byte[in.available()];
in.read(buffer);
response.getOutputStream().write(buffer);
response.getOutputStream().flush();
out.clear();
out = pageContext.pushBody();
最后帮你一把参考,http-://blog.csdn.-net/yfhdsz/archive/2006/09/01/1154491.aspx