title: Spring 3.0 and jackson: posting a composite entitie with ajax+json
body: <p>well i'm working with spring 3.0 in conjunction with ajax and JSON, so i've the next domain class:</p>
  
  <pre><code>public class WebSite {
  int id;
  String description;
  SimpleType type;
  
      //getters and setters ...
      //...
  }
  </code></pre>
  
  <p>The SympleType class is:</p>
  
  <pre><code>public class SimpleType {
  int id;
  
      //getter and setters...
      //...
  }
  </code></pre>
  
  <p>So i created a controller for my first domain class and it goes like:</p>
  
  <pre><code>@Controller
  @RequestMapping(value="/web")
  public class PaginaWebController {
  
      @RequestMapping(method=RequestMethod.GET)
      public String getCreateForm(Model model) {
          model.addAttribute(new WebSite());
          return "web/addWeb";
      }
  
      @RequestMapping(method=RequestMethod.POST)
      public @ResponseBody Map&lt;String, ? extends Object&gt; create(@RequestBody WebSite webSite, HttpServletResponse response) {
          System.out.println("I'm here");
          return null;
      }
  }
  </code></pre>
  
  <p>In my 'addWeb' view i've the following:</p>
  
  <pre><code>&lt;%@ page session="false" %&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %&gt;
  &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %&gt;
  
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Create Web&lt;/title&gt;
          &lt;script type="text/javascript" src="&lt;c:url value="/resources/jquery-1.4.min.js" /&gt; "&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="&lt;c:url value="/resources/json.min.js" /&gt; "&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;
              Create Web
          &lt;/h1&gt;
          &lt;form:form modelAttribute="paginaWeb" action="web" method="post"&gt;
              &lt;fieldset&gt;      
                  &lt;legend&gt;Account Fields&lt;/legend&gt;
                  &lt;p&gt;
                      &lt;form:label id="idLabel" for="id" path="id" cssErrorClass="error"&gt;ID&lt;/form:label&gt;&lt;br/&gt;
                      &lt;form:input path="id" /&gt;&lt;form:errors path="id" /&gt;
                  &lt;/p&gt;
                  &lt;p&gt; 
                      &lt;form:label for="descripcion" path="descripcion" cssErrorClass="error"&gt;descripcion&lt;/form:label&gt;&lt;br/&gt;
                      &lt;form:input path="descripcion" /&gt;&lt;form:errors path="descripcion" /&gt;
                  &lt;/p&gt;
  
                  &lt;p&gt; 
                      &lt;form:label for="tipo" path="tipo" cssErrorClass="error"&gt;Tipo:&lt;/form:label&gt;&lt;br/&gt;
                      &lt;form:input path="tipo" /&gt;&lt;form:errors path="tipo" /&gt;
                  &lt;/p&gt;
  
                  &lt;p&gt; 
                      &lt;input id="create" type="submit" value="Create" /&gt;
                  &lt;/p&gt;
              &lt;/fieldset&gt;
          &lt;/form:form&gt;
      &lt;/body&gt;
  
      &lt;script type="text/javascript"&gt; 
          $(document).ready(function() {
              $("#paginaWeb").submit(function() {
                  var account = $(this).serializeObject();
                  $.postJSON("web", account, function(data) {
                      //some useful code goes here...
                      //...
                  });
                  return false;               
              });
          });
      &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>So, i'm posting the form to the controller using JSON, but it doesn't work, when i'm press submit i get next error:</p>
  
  <pre><code>WARNING: StandardWrapperValve[Spring MVC Dispatcher Servlet]: PWC1406: Servlet.service() for servlet Spring MVC Dispatcher Servlet threw exception
          org.codehaus.jackson.map.JsonMappingException: Can not construct instance of org.springframework.samples.mvc.ajax.account.SimpleType, problem: no suitable creator method found
           at [Source: org.apache.catalina.connector.CoyoteInputStream@f624f7; line: 1, column: 33]
              at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:160)
              at org.codehaus.jackson.map.deser.StdDeserializationContext.instantiationException(StdDeserializationContext.java:214)
              at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromString(BeanDeserializer.java:533)
              at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:355)
      ...
  </code></pre>
  
  <p>Anyone can help me please? i'm really stuck in this one. Any help will be really appreciated.</p>
  
  <p>Cheers!</p>