title: How to call Spring MVC from Javascript?
body: <p>How do you instantiate a custom object from a request param? (I have tried both @ModelAttribute and @RequestParam) </p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST)
  public String newPerson(@ModelAttribute(value = "personModel") 
                            Person person, BindingResult result) {
  // Person has just firstname and lastname fields
   }
  </code></pre>
  
  <p>I try to call this with jQuery using the following code:</p>
  
  <pre><code>var PersonText = '["firstname":"John", "lastname":"Someone"]';
  $.ajax({
  type : 'POST',
  url : "/addnewperson.do",
  data : {'personModel' : personText},
  datatype : 'json',
  success : function(data) {
      var obj = jQuery.parseJSON(data);
  }
  });
  </code></pre>
  
  <p>In fact my original plan was to send an entire list of person objects over to the controller, but since that didn't work I reverted back to a single object, but now that doesn't work either.</p>
  
  <p>EDIT: the param doesn't have to be JSON, I just thought it would make sense to serialize the Javascript object as JSON over to the Spring Controller.</p>