下载问题
下载文件
public String download() throws Exception { OutputStream out = null; String filename = ""; String path = getRequest().getSession().getServletContext().getRealPath(Constant.EXCEL_DOWNLOAD_PATH); File file = new File(path); if (file.exists()) { filename = file.getName(); // set response head filename = new String(filename.getBytes("GBK"), "ISO-8859-1"); getResponse().setContentType("application/octet-stream;charset=GBK"); getResponse().setHeader("Content-disposition","attachment;filename=" + filename); out = FileUtils.exportFile(file, getResponse().getOutputStream()); } else { filename = "文件不存在.txt"; // set response head filename = new String(filename.getBytes("GBK"), "ISO-8859-1"); getResponse().setContentType("application/octet-stream;charset=GBK"); getResponse().setHeader("Content-disposition","attachment;filename=" + filename); out = getResponse().getOutputStream(); } return null;}