title: Spring MultipartFile validation and conversion
body: <p>I currently have a Spring MVC controller that takes a MultipartFile </p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST)
  public String doUpload(@RequestParam("file") final MultipartFile file) {
      /* ... */
  }
  </code></pre>
  
  <p>The file contains csv data which will be used, one per row, to create a list of domain objects. This is working.</p>
  
  <p>I have written a converter for the line data:</p>
  
  <pre><code>class MyObjectConverter implements org.springframework...Converter&lt;String[], MyObject&gt; {
      /* ... */
  }
  </code></pre>
  
  <p>And a Validator for the file </p>
  
  <pre><code>class UploadFileValidator implements org.springframework.validation.Validator { 
      /* ... */
  }
  </code></pre>
  
  <p>And I have a form to do the uploading:</p>
  
  <pre><code>&lt;form method="post" 
      action="&lt;@spring.url '/upload'/&gt;" 
      enctype="multipart/form-data"&gt;
          &lt;input id="upload" type="file" name="file"/&gt;
          &lt;input type="submit" id="uploadButton"/&gt;
      &lt;/form
  </code></pre>
  
  <p>But what I really want to do is tie it all together so that my controller can have a method something like</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST)
  public String doUpload(
      @Valid final List&lt;MyObject&gt; objList, 
      final BindingResult result) { ...}
  </code></pre>
  
  <p>I know that the Spring MVC framework supports converters and validators, but I am failing to understand how to get them to work together.</p>