title: How do I use @Valid with Spring MVC's @RequestBody parameters?
body: <p>I'm having an issue with using <code>@Valid</code> on a parameter to a handler method on my <code>@Controller</code>. My code looks like this:</p>
  
  <pre><code>@RequestMapping(value=BIBBLE_BOBBLE_URI_PATTERN + "/widgets", method=RequestMethod.POST)
  @ResponseBody
  @ResponseStatus(HttpStatus.CREATED)
  public Widget saveNewWidget(
          @PathVariable final String username,
          @PathVariable final String bibbleBobbleName,
          @Valid @RequestBody final Widget widget,
          final BindingResult results,
          final HttpServletRequest request,
          final HttpServletResponse response)
  </code></pre>
  
  <p>where <code>Widget</code> is the class for one of my domain objects. I'm using the <code>@RequestBody</code> annotation to indicate that the payload of the request maps to <code>widget</code> (in my tests, the requests are JSON, though Jackson is on my classpath so I could also use XML).</p>
  
  <p>As you can see, the <code>BindingResult</code> parameter follows directly after the <code>Widget</code> parameter, but I get the following error:</p>
  
  <pre><code>java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature!
  </code></pre>
  
  <p>How do I apply the <code>@Valid</code> annotation to a <code>@RequestBody</code> parameter and then get the results?</p>
  
  <p>P.S. I'm using <code>annotation-driven</code> to handle wiring up the controllers, do content-negotiation, etc.</p>