Well, they beat me to it; the Spring Multipart Issue has been fixed as of Spring 3.0-RC1. I am happy to see that though a little bummed because I was looking forward to fixing it and submitting a patch. Nice work, to whoever fixed it!
I wrote a general posting about how to do file uploads with the new spring annotations (see Spring Multipart Support With Annotations) so now, with the new multi-file support you can have more than one input file with the same form input name.
The input form becomes
1 2 3 4 5 |
to provide two files with the same form field name.
The controller code does not really change much, other than the fact that the multi-file support does not seem to extend to the @RequestParam() annotation support by default, so I had to use a different method signature.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | @Controller @RequestMapping("/upload.do") public class MultifileUpload { @RequestMapping(method=RequestMethod.POST) public ModelAndView upload(final MultipartHttpServletRequest request){ final ModelAndView mav = new ModelAndView("done"); final List<MultipartFile> multipartFiles = request.getFiles("files"); // do stuff with the file System.out.println("found " + multipartFiles.size() + " files"); return mav; } } |
It’s nice to see that this bug got fixed, and they seem to have dropped the provided support for other upload APIs, though you could still write your own implementation as needed.
Popularity: 14% [?]
