

Now that the configuration is set the next step is to create the entry form for the upload. The mvc-config.xml configuration file doesn't need anything special for multipart uploads so I'll skip listing it here, have a look in the zip file if you are interested in its contents. The above app-config.xml configuration file is referenced from the mvc-config.xml configuration file.

In documentation you will see that they talk about using a "multipart resolver" and that can be found at the end of web/WEB-INF/spring/app-config.xml: It touches on what needs to be done but leaves out a full example. Next it is worth a quick look at the information provided in the Spring documentation about MVC multipart. If you want to use the example project from the zip just copy all the jar files to the lib directory. For the file upload part there are two non-Spring dependencies as well: Apache Commons FileUpload and Apache Commons IO.

Grab a copy of the Spring 3 libraries, at this time the latest version is spring-framework-3.0.1.RELEASE-A.zip and that is what I used for the following example. There is a decent amount of boiler plate work so I've created a project zip file with all the code, a build file and configuration in it (you just need to add the libraries).įirst lets start by gathering up all the libraries we are going to need (see the end of the post for the directory layout I used or just unzip the project). If you want a simple MVC example to start with check out their SVN MVC-Basic sample. I'm going to assume you know something about Spring and their MVC configuration in general. What follows is a complete example of how to do MVC based file uploads with Spring 3. I had the opportunity to figure out how to do file uploads using Spring 3 the other day and I couldn't find anything that pulled it all together.
