title: Spring MVC + Ajax error 400
body: <p>I have a simple java application on Spring MVC and I send ajax request to Spring controller. When I set headers <strong>"Accept", "application/json"</strong> and <strong>"Content-Type", "application/json;charset=utf-8"</strong> in AJAX call I get <strong><em>error 400</em></strong> in dubugger, when I delete it I get <strong><em>error 415</em></strong>.</p>
  
  <p>If I change controller method signature to <strong><em>public String logoutPage (@RequestBody String obyavleniye)</em></strong> I get JSON string. What problem can be with parse request in controller?</p>
  
  <p>JS method:</p>
  
  <pre><code>$("#advertForm").submit(function(e) {
          e.preventDefault();
          var token = $("meta[name='_csrf']").attr("content");
          var header = $("meta[name='_csrf_header']").attr("content");
          var obyavleniye = {
              title: "Title",
              price: "80",
              description: "desc",
              date: "2016-11-07 18:30:21",
              authorid: "2",
              category: "A",
              state: "new",
              img1: "http",
              img2: "http",
              img3: "http",
              img4: "http",
          };
          var post_data = JSON.stringify(obyavleniye);
  
          console.log(post_data);
          $.ajax({
              url : "/upload",
              type: "POST",
              dataType: 'json',
              data: post_data,
              beforeSend: function(xhr) {
                  xhr.setRequestHeader("Accept", "application/json");
                  xhr.setRequestHeader("Content-Type", "application/json;charset=utf-8");
                  xhr.setRequestHeader(header, token);
              },
              complete: function() {
                  console.log("Sent");
              },
              success: function (response) {
                  console.log("success");
                  console.log("response" + response);
              },
              error: function (data) {
                  console.log("error");
                  console.log(data);
              }
          });
      });
  </code></pre>
  
  <p>Controller method:</p>
  
  <pre><code>@ResponseBody
      @RequestMapping(value="/upload", method = RequestMethod.POST)
      public String logoutPage (@RequestBody Advert obyavleniye) {
  //    public String logoutPage (@RequestBody String obyavleniye) {
          System.out.println("Enter: " + obyavleniye);
          this.advertService.addAdvert(obyavleniye);
  //        return "{\"msg\":\"success\"}";
          return "{\"title\":\"Title\",\"price\":\"80\",\"description\":\"normm\",\"date\":\"2016-11-07 18:30:21\",\"authorid\":\"2\",\"category\":\"A\",\"state\":\"new\",\"img1\":\"http\",\"img2\":\"http\",\"img3\":\"http\",\"img4\":\"http\"}";
      }
  </code></pre>