title: Converting @RequestBody to an object
body: <p>Guys, Well I have done enough research still I can't find the solution to this.</p>
  
  <p>In a nutshell, I'm simply passing url encoded form data to the Controller method and trying to convert it as a domain object which has Date and integers.</p>
  
  <pre><code>@RequestMapping(value = "/savePassport", method = RequestMethod.POST)
      public @ResponseBody
      AjaxResponse savePassport(@RequestBody StaffPassport passport, HttpServletResponse response) {
  
      // Some operations.
  </code></pre>
  
  <p>}</p>
  
  <p>The Staff Passport looks like this:</p>
  
  <pre><code>import java.sql.Date;
  
  public class StaffPassport {
  
      private int staffId;
      private String passportNumber;
      private String placeOfIssue;
      private Date issueDate;
      private Date expiryDate;
      private String spouseName;
      private String oldPassportRef;
      private String visaInfo;
      private String description;
  //gets/sets
  }
  </code></pre>
  
  <p>When I invoke the /savePassport, I get unsupported media exception. I guess it's related to casting.</p>
  
  <p>I can't this working right. Of course I can catch individual form data using @RequestParam and manually do the casting but that's not the point of a framework isn't it?</p>
  
  <p>Where am I going wrong? And you are right. I'm a beginner in Spring, but I love it.</p>