1.后端
后端方法的放回值类型和接收参数
后端以流的形式返回到前端
// 设置生成的Excel的文件名,并以中文进行编码 String codedFileName = "****表"; System.err.println("codedFileName: " + codedFileName); response.setHeader("Content-Disposition", "attachment;filename=" + codedFileName + ".xlsx"); // 响应类型,编码 response.setContentType("application/octet-stream;charset=UTF-8"); // 形成输出流 OutputStream osOut = response.getOutputStream(); // 将指定的字节写入此输出流 wb.write(osOut); // 刷新此输出流并强制将所有缓冲的输出字节被写出 osOut.flush(); // 关闭流 osOut.close(); wb.close();
2.前端
//导出按钮 exportstaffgrade: