后台:
ServletOutputStream os = response.getOutputStream();
String mimeType = "application/msexcel";
response.setContentType(mimeType);
String headerKey = "Content-Disposition";
String headerValue = String.format("attachment; filename=\"%s\"","应收账单.xlsx");
response.setHeader(headerKey, headerValue);
前台:
axios({
url:'/msArCharge/downloadBill/' +this.charge.columnArr,
method: 'get',
responseType: 'blob'
}).then((response) => {
const blob = new Blob(
[response.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8' })
const aEle = document.createElement('a'); // 创建a标签
const href &