title: Spring MVC @RequestBody receive an Object wrapper with non-primitive attributes
body: <p>I create the JSON as follows:</p>
  
  <pre><code>    var manager = {
          username: "admin",
          password: "admin"
      };
      var userToSubscribe = {
          username: "newuser",
          password: "newpassword",
          email: "user@1and1.es"
      };
  
      var openid = "myopenid";
  
      var subscription = {
              manager: manager,
              userToSubscribe : userToSubscribe,
              openid : openid
      };
  
      $.ajax({
          url: '/myapp/rest/subscribeUser.json',
          type: 'POST',
          dataType: 'json',
          contentType: 'application/json',
          mimeType: 'application/json',
          data: JSON.stringify({subscription : subscription})   
      });
  </code></pre>
  
  <p>This is the JSON that is sent:</p>
  
  <pre><code>{"subscription":{"manager":{"username":"admin","password":"admin"},"userToSubscribe":{"username":"newuser","password":"newpassword","email":"user@1and1.es"},"openid":"myopenid"}}  
  </code></pre>
  
  <p>And I would like to map this JSON to a Wrapper Class. This is the wrapper:</p>
  
  <pre><code>private class Subscription{
      private User manager;
      private User userToSubscribe;
      private String openid;
      public User getManager() {
          return manager;
      }
      public void setManager(User manager) {
          this.manager = manager;
      }
      public User getUserToSubscribe() {
          return userToSubscribe;
      }
      public void setUserToSubscribe(User userToSubscribe) {
          this.userToSubscribe = userToSubscribe;
      }
      public String getOpenid() {
          return openid;
      }
      public void setOpenid(String openid) {
          this.openid = openid;
      }
  }
  </code></pre>
  
  <p>The jackson dependency in the pom.xml (I'm using spring 3.1.0.RELEASE):</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
          &lt;version&gt;1.9.10&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>The mapping in rest-servlet.xml</p>
  
  <pre><code>&lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt;
     &lt;property name="messageConverters"&gt;
         &lt;list&gt;
             &lt;ref bean="jsonConverter" /&gt;
         &lt;/list&gt;
     &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"&gt;
     &lt;property name="supportedMediaTypes" value="application/json" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>And the header of the controller method:</p>
  
  <pre><code>public @ResponseBody SimpleMessage subscribeUser(@RequestBody Subscription subscription)
  </code></pre>
  
  <p>As a result of the POST I receive a 400 Incorrect request error. Is it possible to do this or do i need to do it with <code>@RequestBody</code> String or <code>@RequestBody Map&lt;String,Object&gt;</code> and decode the JSON myself?</p>
  
  <p>Thanks!</p>