@POST
@At("/down")
@Ok("raw")
public File download(HttpServletRequest request) throws UnsupportedEncodingException {
File file = new File("name");
if(file.exists() && file.isFile()){
return file;
}
return null;
}
3 回复
@At("/down")
@Ok("raw")
public File download(HttpServletRequest request, HttpServletResponse response) throws IOException {
File file = new File("pathname");
response.reset();
response.setHeader("Content-Disposition", "attachment; filename=animate.css");
// response.addHeader("Content-Length", "" + file);
response.setContentType("application/octet-stream; charset=UTF-8");
if(file.exists() && file.isFile()){
return file;
}
return null;
}
this.$axios.get(API_SYS_USER_EXPORT, {
responseType: 'blob',
params: this.pageData
}).then(res => {
const url = window.URL.createObjectURL(new Blob([res.data]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', 'sys_user.xlsx')
document.body.appendChild(link)
link.click()
})
添加回复
请先登陆