upload.parse(request) 为null
Spring 的容器内配置了路径为rg.springframework.web.multipart.commons.CommonsMultipartResolver的bean,
在Controller内单独调用common-fileupload组件:
DiskFileUpload dfu =new DiskFileUpload();
List list = dfu.parseRequest(request);
这里获取的list会为NULL.注册到Spring的cmmonsMultipartResolver应该对Request做过解析,这里再去解析得到的值则为空.
if(!multipartResolver.isMultipart(request)){
throw new IllegalArgumentException(String.format("请选择需要上传的文件!"));
}
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartFile file = multipartRequest.getFile("imgFile");
String fileName = file.getOriginalFilename();