@GetMapping(value = "/downLoad")
@ApiOperation(value = "卡券模板下载", notes = "卡券模板下载")
public void downLoad(HttpServletResponse response){
try {
//获取要下载的模板名称
String fileName = "卡券模板.xlsx";
response.setHeader("Content-disposition", "attachment;filename=" +
URLEncoder.encode(fileName, "UTF-8"));
// 通知客服文件的MIME类型
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
//cardTmplateUrl:服务器excel地址
URL url = new URL(cardTmplateUrl);
InputStream input = url.openStream();
//FileInputStream input = new FileInputStream(path);
OutputStream out = response.getOutputStream();
byte[] b = new byte[1024];
int len;
while ((len = input.read(b)) != -1) {
out.write(b, 0, len);
}
input.close();
} catch (Exception e) {
e.printStackTrace();
}
}