title: Spring 3 MVC - using domain objects as @RequestBody
body: <p>I am thinking of using domain object as @RequestBody. My domain objects are immutable objects and so they do not have any setter methods. Its a application/json request and I am using Jackson message converter. </p>
  
  <pre><code>@RequestMapping(value="/user", method=RequestMethod.POST)
  @ResponseStatus(HttpStatus.NO_CONTENT)
  public @ResponseBody void createUser(@RequestBody User user) {
      .......... 
  }
  </code></pre>
  
  <p>Since I do not have setter methods inside my user object, when I do a POST request to "/user", I get UnrecognizedPropertyException from MappingJacksonHttpMessageConverter. Is there a way in spring in which I would be able to assign data using a static factory method(or constructor) of user object instead of setters.</p>