title: 415 error while ajax post in spring rest
body: <p>after solving this <a href="https://stackoverflow.com/questions/28199272/do-we-have-to-have-to-post-json-object-with-exactly-same-fields-as-in-pojo-objec/28200607?noredirect=1#comment44897889_28200607">Do we have to have to post json object with exactly same fields as in pojo object in controller?</a> im getting 415 error while posting from AJAX ,I m using spring rest . And yes i have seen other similar questions but non of them solved my problem</p>
  
  <p>controller:</p>
  
  <pre><code>@RequestMapping(value = "/createTest", method = RequestMethod.POST )
  
  public  @ResponseBody String createTest(@RequestBody TestJsonDTO testJson)
          throws JsonProcessingException, IOException {
      TestSet test = new TestSet();
      //................
  </code></pre>
  
  <p>AJAX:</p>
  
  <pre><code>         function createTest() {
  $.ajax({
      type : 'POST',
      url : "http://localhost:8085/annotationBased/admin/createTest",
      dataType : "json",
      accept:"application/json",
      contentType : "application/json",
      data : testToJSON(),
  
      success : function() {
          alert("success")
      },
      complete : function(){
          findAllTEst()
          alert("OK")
  
      },  
  
  });
   function testToJSON() {
  
  listOfQuestionForTest = questionToAdd;
  return JSON.stringify({
  
      "testSet" : {name : $('#testname').val(),
          fullmark : parseInt($('#fullmark').val()),
          passmark : parseInt($('#passmark').val())},
      "questionsInTest" : listOfQuestionForTest
  // "testDate":$('#testDate').value()
  })
  </code></pre>
  
  <p>}</p>
  
  <p>and i have added those class u suggested.</p>