title: How to Insert JSON data object to Spring MVC application (via controller) with Jquery
body: <p>I want to Insert JSON data object (User) to my Spring MVC application (via controller) with Jquery. if code is like follow how can I accomplish this? Thanks.</p>
  
  <h2>User Object</h2>
  
  <pre><code>public class User {
      private Integer usId;
      private String usName;
      private Boolean usActive;
  }
  </code></pre>
  
  <h2>Spring Controller</h2>
  
  <pre><code>@Controller
  @RequestMapping(value="/user")
  public class UserController {
  
      @Autowired
      UserService userService;
  
      private Validator validator;
  
      @RequestMapping(method=RequestMethod.POST)
      public @ResponseBody Map&lt;String, ? extends Object&gt; create(@RequestBody User user, HttpServletResponse response) {
  
  
          Set&lt;ConstraintViolation&lt;User&gt;&gt; failures = validator.validate(user);
          userService.insert(user);
  
          if (!failures.isEmpty()) {
              response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
              return validationMessages(failures);
          } else {
  
              return Collections.singletonMap("id", user.getUsId());
          }
      }
  }
  </code></pre>