title: Unsupported Media Type Error in AJAX-Spring MVC
body: <p>I am trying to pass string to controller use of Ajax Stringify but i got this error 
  <strong>415 (Unsupported Media Type)</strong> 
  My Ajax call:</p>
  
  <pre><code>$.ajax({
       type: "POST",
       contentType : 'application/json; charset=utf-8',
       dataType : 'json',
       url: "addSample",
       data: JSON.stringify(search), // Note it is important
       cache : false,
       beforeSend : function(xhr) {
          xhr.setRequestHeader("Accept", "application/json");
          xhr.setRequestHeader("Content-Type", "application/json");
       },
       success : function(response) {
           console.log("Success: "+ response);            
       },
       error : function(xhr) {
           console.log("Sorry, there was a problem! " + xhr.responseText);
       },
       complete : function() {
           console.log("Request complete");
       }
  });
  </code></pre>
  
  <p>Passing the String :</p>
  
  <pre><code>var search = {
       " name" : "aa",
        "sname": "bb",
        "dname" : "cc"
  }
  </code></pre>
  
  <p>My spring controller function:</p>
  
  <pre><code>@RequestMapping(headers={"Accept=application/json"},value = "addSample", method = RequestMethod.POST)
      public @ResponseBody
      String addData(HttpServletRequest request,@RequestBody final DemoDTO demoDTO)
      {
          return  "{\"value\":\"true\"}";
      }
  </code></pre>
  
  <p>My DTO:</p>
  
  <pre><code>public class DemoDTO implements Serializable{
      private String name;
      private String sname;
      private String dname;
    //getter setter
  }
  </code></pre>
  
  <p>Please help me for solving this....</p>