title: How to bind uploaded file to form object property?
body: <p>I would like to have the form object like this:</p>
  
  <pre><code>public class FormData {
  
      private MultipartFile file1;
  
      private MultipartFile file2;
  
      // setters/getters for above fields and other properties
  }
  </code></pre>
  
  <p>and I would like SpringMVC to bind e.g. <code>&lt;input type="file" name="file1"&gt;</code> HTML form field to my form object property. I haven't found any JSP tag for that (like <code>&lt;form:file path="file1" /&gt;</code> or <code>&lt;form:input type="file" path="file1" /&gt;</code>) in <code>spring-form.tld</code>. Is it possible at all? If not, is this limitation rooted too deep in Spring internals and cannot be easily overcome?</p>
  
  <p>I know how to bind file upload form value to controller method argument (described in <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-multipart" rel="nofollow">documentation</a>):</p>
  
  <pre><code>@RequestMapping(value = {"/"}, method = RequestMethod.POST)
  public ModelAndView compare(@ModelAttribute(FORM_BEAN_NAME) FormData formData,
      @RequestParam("file1") MultipartFile file1,
      @RequestParam("file2") MultipartFile file2,
      BindingResult bindingResult) {
  </code></pre>
  
  <p>but I would be happier if all HTML form elements are bound to one class and method signature does not boost when new upload fields are added.</p>