title: send data AJAX to @RequestBody Spring
body: <p>I use response entity and request body for inserting data in spring java but I found an error. 404 not found.</p>
  
  <p>my controller:</p>
  
  <pre><code>@RequestMapping(value = "insertuserlogin/", method = RequestMethod.POST)
  public ResponseEntity&lt;?&gt; createUser(@Valid @RequestBody UserLogin user, BindingResult bindingResult,
          Validation validation, Errors error) {
      Map&lt;?, ?&gt; result = new HashMap&lt;Object, Object&gt;();
      if (bindingResult.hasErrors()) {
          String errorMessage = bindingResult.getFieldErrors().iterator().next().getDefaultMessage();
          System.out.println(errorMessage);
          return new ResponseEntity&lt;&gt;(errorMessage, HttpStatus.UNPROCESSABLE_ENTITY);
      } else {
          uls.saveUser(user);
          return new ResponseEntity&lt;&gt;(result, HttpStatus.ACCEPTED);           
      }
  }
  </code></pre>
  
  <p>ajax:</p>
  
  <pre><code>    var data = { "description": "string", "id": 10, "username": "barubanget"}
      $.ajax({
          data: JSON.stringify(data),
          dataType: 'json',
          url : "http://localhost:8085/TaspenNCBSpring/insertuserlogin",
          type : 'POST',
          success : function(data) {
              console.log("success post!");
          },
          error : function(e) {
              console.log("error: " + e);
          }
      });     
  </code></pre>
  
  <p>How to fix this problem? what a format data from request body? Thanks. Bobby</p>