Advertisement
Guest User

Untitled

a guest
Nov 7th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. var user = {
  2. "username" : "test",
  3. "password" : "test",
  4. "ID" : 1
  5. };
  6. $.ajax({
  7. url: "/test1",
  8. type: "POST",
  9. data: JSON.stringify(user),
  10. contentType:"application/json; charset=utf-8",
  11. success: function() {
  12. alert("success")
  13. }
  14. })
  15.  
  16. @RequestMapping(value = "/test1")
  17. public String test2(@RequestBody User user) {
  18.  
  19. //Can't receive the Param.
  20. // console result : null
  21. System.out.println(user.getAge());
  22.  
  23. //Nothing wrong
  24. //console result:
  25. // username: test
  26. // password: test
  27. System.out.println(user.getUsername());
  28. System.out.println(user.getPassword());
  29. return "test";
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement