67,513
社区成员
发帖
与我相关
我的任务
分享
public String download() throws Exception {
try {
String filePath = servletRequest.getParameter("filePath");
File file = new File(filePath);
String fileName = file.getName().replaceAll("\\[.+\\]", "");
fileName = URLEncoder.encode(fileName, "utf-8");
fileName = fileName.replace('+', ' ');
servletResponse.setContentType("application/x-download");
servletResponse.addHeader("Content-Disposition",
"attachment;filename=" + fileName);
excelStream = new FileInputStream(file);
}
catch(Exception e) {
write(Tool.getErrorMsg(e.getMessage()));
return ERROR;
}
return SUCCESS;
}