}
sheet.setColumnWidth(3, 20 * 256);
sheet.setColumnWidth(4, 40 * 256);
sheet.setColumnWidth(5, 20 * 256);
sheet.setColumnWidth(6, 50 * 256);
wb.write(os);
os.close();
json.setSuccess(true);
json.setMsg("导出成功");
downLoad(filePath, targetFile, targetName);//从这往后代码就不执行了------求解决??
} catch (Exception e) {
e.printStackTrace();
log.error("export remark wrong" + e);
json.setMsg("导出失败");
}
super.writeJson(json);
-----------下载的代码-----------
public void downLoad(String realPath, File file, String fileName)
throws IOException {
HttpServletResponse response = ServletActionContext.getResponse();
PrintWriter out = response.getWriter();
response.resetBuffer();
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition", "attachment; filename="
+ fileName);
// 写出流信息
int b = 0;
try {
// 这里的 response 就是你 servlet 的那个传参进来的 response
FileInputStream fis = new FileInputStream(file);
while ((b = fis.read()) != -1) {
out.write(b);
}
} catch (IOException e) {
throw e;
} finally {
out.close();
}
catch (Exception e) 也没捕捉到异常么?
没有异常 捕捉什么异常?
只要一执行下载,后面的代码就不执行了
@会动的语言: downLoad方法调试进去,能够执行到方法结束吗?