Advertisement
Guest User

Untitled

a guest
Apr 13th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. var user ={
  2. "id" : "1",
  3. "username" : "hello",
  4. "password" : "123456"
  5. };
  6. console.log(user);
  7. var response = $http.post("/login/signup",user);
  8. response.success(function (data) {
  9. alert("success");
  10. alert(data);
  11. });
  12. response.error(function (data) {
  13. alert("error");
  14. alert(data);
  15. });
  16.  
  17. public class User {
  18. private long userID;
  19. private String username;
  20. private String password;
  21.  
  22. public User(){
  23.  
  24. }
  25.  
  26. public User(long userID, String username, String password) {
  27. this.userID = userID;
  28. this.username = username;
  29. this.password = password;
  30. }
  31.  
  32.  
  33. public long getUserID() {
  34. return userID;
  35. }
  36.  
  37. public void setUserID(long userID) {
  38. this.userID = userID;
  39. }
  40.  
  41. public String getUsername() {
  42. return username;
  43. }
  44.  
  45. public void setUsername(String username) {
  46. this.username = username;
  47. }
  48.  
  49. public String getPassword() {
  50. return password;
  51. }
  52.  
  53. public void setPassword(String password) {
  54. this.password = password;
  55. }
  56. }
  57.  
  58. @Controller
  59. @RequestMapping(value = "/login")
  60. public class LoginController {
  61.  
  62. @RequestMapping(value = "/signup",method = RequestMethod.POST)
  63. public String signUp(User user){
  64. String username = user.getUsername();// NULL!!
  65. System.out.println(username);
  66. return "login";
  67. }
  68.  
  69. }
  70.  
  71. @RequestMapping(value = "/signup",method = RequestMethod.POST)
  72. public String signUp(@RequestBody User user){
  73. String username = user.getUsername();
  74. System.out.println(username);
  75. return "login";
  76. }
  77.  
  78. The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement