1:引入 包
<dependency><groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.27</version>
</dependency> 2前端代码:
downloadFile1(fileUrl, filename) {
if(filename==null||filename==""){
this.$modal.msgError("文件名为空,无法下载")
return
}
if(filename.indexOf(".pdf") !== -1){
//return
}else{
//
let hz = [".png",".jpg",".jpeg",".bmp",".gif"];
let name = "."+filename.split(".")[1];
if(hz.indexOf(name) !== -1){
}else{
this.$modal.msgError("只能导出 图片 或是 pdf 文件")
return
}
}
//网络图片路径 文件名
let queryParams = {"fileUrl":fileUrl,"filename":filename};
this.download('/fileWatermark/download', {
...queryParams
}, filename)
}
3:后端
标签:vue,return,Springboot,filename,let,pdf,fileUrl,图片 From: https://www.cnblogs.com/xueershewang/p/18145131