I am trying to upload multiple files using spring 3.1.2 with @Controller and @RequestMapping.
Here\'s what I did and my configuration.
Html5 form :
<
Have included commons-fileupload dependency?
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
</dependency>
I tested the fileupload works fine even with ArrayList as the parameter type on the controller handler
Although you've already gotten your answer thanks to Alex, I'd just like to elaborate a bit. With Spring binding, form fields are bound to their "name" attributes in the HTML. Since it is impossible to have a form field named files[] (if one declares a variable name with that syntax, its name is files, but it is an array of the declaring type), Spring couldn't match it up - and the behavior in that case is to disregard the data in the request.
Using a type such as MultipartFile, you can use either a List named "files" or an array as the following examples:
private List<MultipartFile> files;
private MultipartFile[] files;
With appropriate getters and setters, you can then access and mutate the file list accordingly.