title: Spring MVC with jquery post call
body: <p>Hi everyone: i have an endpoint configured something like this in spring mvc</p>
  
  <pre><code>@RequestMapping("/path/to/endpoint")
      public void pathToEndPoint(@RequestBody String body ){
          //do stuff with body
      }
  </code></pre>
  
  <p>and then in my html i am doing this:</p>
  
  <pre><code>var data ; //a json object
   $.post( "/path/to/endpoint", data );
  </code></pre>
  
  <p>the problem is that when spring sees that the request body is in fact a json object it seems to want to map these object attributes to a java class and when it sees that i have given it a string as a argument it does not know how to map this.</p>
  
  <p>In other words, spring seems to be trying to be too clever, i actually just want the string representation of my request body; in other words i want the json and not a pojo because it is in the format i require it to be in further down the line.</p>
  
  <p>how do i get spring to stop trying to be helpful and just put the raw request body into a string for me?</p>
  
  <p>thanks for any help provided.</p>
  
  <p>Update</p>
  
  <p>it appears spring reads a buffered reader which turns out to be empty to it seems my ajax call is not sending any data, or the data attribute does not map to the request body. really clutching at straws over this.</p>