title: Spring 3.2 Validate Request Param, ControllerAdvice not formatting response
body: <p>I'm using JSR 303 <code>@Valid</code> to validate multiple request params in a controller, the params posted along with a <code>MultipartFile</code>.</p>
  
  <p>The validation part of this seems to be working,</p>
  
  <pre><code>@RequestMapping(value = "/upload", method = RequestMethod.POST)
  public @ResponseBody
  Response upload(@RequestParam(value = "file", required = true) MultipartFile file,
                  @Valid ValidBean bean) {
  
      //method
  }
  </code></pre>
  
  <p><code>ValidBean</code> is a collection of Strings, Longs and a <code>List&lt;String&gt;</code>.</p>
  
  <pre><code>public class ValidBean{
     @NotNull
     String someString;
  
     @Size(min = 1, max=10)
     String anotherString;
  
     //getters, setters, random been goodness 
  
  
  }
  </code></pre>
  
  <p>It seems that the client is getting rejected if the posted params do not match what is defined in <code>ValidBean</code>.</p>
  
  <p>Where I am having an issue is with my global <code>@ControllerAdvice ValidationHandler</code>. </p>
  
  <pre><code>@ControllerAdvice
  public class ValidationHandler {
  
  @ExceptionHandler
  @ResponseStatus(value = HttpStatus.BAD_REQUEST)
  public @ResponseBody
  StatusContext handleArgumentNotValid( MethodArgumentNotValidException error ){
      //format and return response 
  }
  </code></pre>
  
  <p>My <code>@ExceptionHandler</code> only seems to be used in methods that use <code>@RequestBody @Valid</code></p>
  
  <p>So this method returns a formatted response, </p>
  
  <pre><code>@RequestMapping(value = "/works", method = RequestMethod.POST)
  public @ResponseBody
  Formatted addUser(@RequestBody @Valid ValidBean user)
  </code></pre>
  
  <p>And this one does not,</p>
  
  <pre><code>@RequestMapping(value = "/noGood", method = RequestMethod.POST)
  public @ResponseBody
  NotFormatted addUser(@Valid ValidBean user)
  </code></pre>
  
  <p>Though both do seem to actually perform validation.</p>