spring mvc 接收所有前端上传文件
@PostMapping(value = "/upload/file") public XXX uploadFile(HttpServletRequest request) throws Exception { MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest) request; Iterator<String> fileNames = multipartHttpServletRequest.getFileNames(); List<String> nameList = Lists.newArrayList(fileNames); log.info("请求的文件名称为:{}", nameList); for (String s : nameList) { List<MultipartFile> files = multipartHttpServletRequest.getFiles(s); log.info("请求的文件名称为:{},数量为:{}", s, files.size()); for (MultipartFile file : files) { // 操作 } } return XXX; }