title: RequestMapping with POST in Spring not working?
body: <p>Hi I have the following ajax call in my client side.</p>
  <pre><code> var arr = JSON.stringify(JSON_Array);
   $.ajax({
              url: 'http://localhost:8080/',
              type: 'POST',
              data: arr,
              dataType: 'text',
              contentType: 'application/json',
              success: function () {
                  console.log(&quot;Success!&quot;);
              },
              error: function() {
                  console.log(&quot;error&quot;);
              },
              
          });
  </code></pre>
  <p>Server side:</p>
  <pre><code>@Controller
  public class Controller{
      @RequestMapping(&quot;/&quot;)
      public String start() {
          System.out.println(&quot;works&quot;); //prints
          return &quot;index&quot;;
      }
  
      @RequestMapping(value = &quot;/&quot;, method = RequestMethod.POST, consumes = &quot;text/plain&quot;)
      public void process(@RequestBody String payload) throws Exception {
          System.out.println(&quot;payload &quot;  + payload); //does not print
      }
  }
  </code></pre>
  <p>The ajax call is successfully sent off, however nothing is received in the server side. The process method is not being used. I am not too sure why. Help would be appreciated.</p>
  <p>edit:
  Changes made following @Toofy's comment</p>
  <p>In Ajax call:</p>
  <pre><code>dataType: 'text',
  contentType: &quot;text/plain;&quot;,
  </code></pre>
  <p>process method kept the same.</p>
  <p>I also tried changing the Ajax call to the following</p>
  <pre><code>dataType: 'json',
  contentType: &quot;application/json;&quot;,
  </code></pre>
  <p>and the server side changes:</p>
  <pre><code>@RequestMapping(value = &quot;/&quot;, method = RequestMethod.POST, consumes = &quot;application/json&quot;)
      public void process(@RequestBody String payload) throws Exception {
          System.out.println(&quot;payload &quot;  + payload);
      }
  </code></pre>
  <p>in both these cases the ajax calls stop working</p>