public class MultiPartFileBean { private List<MultipartFile> files; public void setFiles(List<MultipartFile> files) { this.files = files; } public List<MultipartFile> getFiles() { return files; } } <form method="post" action="/form" enctype="multipart/form-data"> <input type="text" name="name"/> <input type="file" name="file"/> <input type="submit"/> </form> 文件批量上传 @RequestMapping(value = "/form", method = RequestMethod.POST) public String handleFormUpload(@RequestParam("name") String name, @RequestParam("file") MultipartFile file) { if (!file.isEmpty()) { byte[] bytes = file.getBytes(); // store the bytes somewhere return "redirect:uploadSuccess"; } else { return "redirect:uploadFailure"; } } @RequestMapping(value = "/uploadtest", method = RequestMethod.POST) public String uploadtestProcess(MultiPartFileUploadBean file, BindingResult bindingResult, Model model) throws IOException { ... // binding check StringBuilder sb = new StringBuilder(); List<MultipartFile> files = file.getFiles(); for(MultipartFile f:files) sb.append(String.format("File: %s, contains: %s<br/>/n",f.getOriginalFilename(),new String(f.getBytes()))); String content = sb.toString(); model.addAttribute("content", content); return "uploadtest"; } <form method="post" action="/uploadtest" enctype="multipart/form-data"> <p>Type: <input type="text" name="type" value="multiPartFileSingle" size="60" /></p> <p>File 1: <input type="file" name="files[0]" size="60" /></p> <p>File 2: <input type="file" name="files[1]" size="60" /></p> <p><input type="submit" value="Upload" /></p> </form> <c:if test="${not empty content}"> <p>The content uploaded: <br/>${content}</p>