Java后端接收 POST
@ApiOperation(value = "添加测试报告信息", notes = "添加测试报告信息") @EnableAuth @PostMapping(value = "/saveTestReport") @Transactional(rollbackFor = Exception.class) public ResultData saveTestReport(@RequestParam(value = "files") Listfiles, TestReport testReport) {
前端核心代码:
点击上传 只能上传pdf文件
fillFormData(){ let formData = new FormData(); let MultipartFiles; if (this.dialogInfo.type==='1'){//pdf MultipartFiles = this.$refs['MultipartFile'].uploadFiles;//文件 }else{//图片 MultipartFiles = this.$refs['MultipartFile1'].uploadFiles;//文件 } if(MultipartFiles===undefined){ this.$message.error("请上传文件"); return false; } this.dialogInfo.unitName=this.selectValHome1 for(let key in this.dialogInfo){ formData.append(key, this.dialogInfo[key]); } for(let i=0;i