controller使用void也行
InputStream isTemplate = this.getClass().getClassLoader().getResourceAsStream("templates/meet/testModel.docx");
String filename = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + "_测试表.docx";
Map param = new HashMap();
param.put("参数key","sdf");
XWPFTemplate template = XWPFTemplate.compile(isTemplate).render(param);
filename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
response.addHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes()));
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
OutputStream os = new BufferedOutputStream(response.getOutputStream());
template.write(os);
os.flush();
os.close();
templates文件夹下中
可以用window.location.href
或者生成a标签的方式(在复杂模板下载中提到)