title: @RequestBody validation in spring 3.0.5
body: <p>I have a REST controller and am trying to ensure that the request body is truly of the type I think it will be.</p>
  
  <p>For example:</p>
  
  <pre><code>@Controller
  public class myController{
  
     @RequestMapping(method=RequestMethod.POST, value = "/addFoo", headers="...")
     public @ResponseBody String addFoo(@RequestBody Foo){
     ...code to add a new Foo
     }
  }
  </code></pre>
  
  <p><br>
  Unfortunately someone could post a Bar object instead of a Foo object and I want to intercept that occurrence and return a sternly worded message about Barring my Foo -- instead of having Spring throw a mapping error and returning a 500 Internal Server Error.</p>
  
  <p>What's the best way to handle this?<br>
  I'm using Spring 3.0.5.</p>