利用formData实现多文件上传

1.前端

let formDatas = new FormData();
let fileList = this.workFlowData.fileList;
fileList.forEach(file=>{
    formDatas.append('files',file);
});
formDatas.append('number',this.workFlowData.number);
post(enterpriseInnerService.startWorkflow,formDatas).then(data => {

}).catch(({err}) => {
    this.$message.error('上传失败');
})

2.后端

@RequestMapping(path = "/startWorkflow", method = RequestMethod.POST)
public void startWorkflow(
    HttpServletRequest req,
    @RequestParam("files") MultipartFile [] files,
    String number
) {
    if(files.length > 0){
        for(int i=0,len=files.length;i 
 

你可能感兴趣的:(其他)