首先,java后台是没有问题的,因为我用postman测试过,向后台传文件时处理是没有问题的。
但是用nginx服务器部署前端项目时,发送excel文件到后台处理时会报400错误,
文件很小只有10k,不考虑nginx的文件上传大小限制。
然后就是别的请求都可以正常通信,就是前端的文件处理有问题。
附一段前端接口代码:
confirmUpload() { //确认上传
var file = new FormData();
this.fileList.forEach((val) => {
file.append("file", val.raw);
console.log(val.raw);
}
);
console.log(file)
axios.post("/weixin/excelimport", file)
.then((res) => {
if(res.data.state == 200){
data.dialoglist = res.data.pidlist;
ElMessage({
message: '读取成功',
type: 'success',
})
data.dialogOfUpload = false
data.addpid=true
}else {
ElMessage({
message: '读取失败',
type: 'error',
})
}
}).catch(error => {
console.log(error);
});
},
