ngfileupload 上传文件对家java restful 接口的:required ‘file’ not present 问题解决

首先,贴上错误前端错误代码:

	<button class="btn btn-primary">
        	<i class="fa fa-upload m-r-sm"></i> 上传文件
        	<div style="position: absolute; top: 0px; left: 0px; width: 150px; height: 57px; overflow: hidden; bottom: auto; right: auto;">
       		   <input data-ng-disabled="false"  class="form-control" type="file" name="file"
                	 ngf-select="uploadFiles($file)"
                 	ng-model="uploadfile"  ngf-max-size="1.1GB" placeholder=""
                 	style="height:47px;position: absolute;opacity:0;cursor:pointer" required>
       		 </div>
      </button>
后端restful 接口部分代码:

 @RequestMapping(value = "/upload", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public UploadSuccess uploadExcel(@RequestParam("file") MultipartFile files) {
			.....
}
调了半天始终出现错误:


始终说file 参数不存在,该问题主要由html 代码里面的 name=“file”引起,只需要把那么改为不叫file 的其它值就可以了。

你可能感兴趣的:(java,前端)