2017-03-04 80 views
-2
@RequestMapping(path = "/registrationuser", method = RequestMethod.POST, produces=MediaType.APPLICATION_JSON_VALUE, consumes=MediaType.APPLICATION_JSON_VALUE) 
public ResponseEntity<?> getUserDetails(@RequestBody Map<String, Object> input) throws commonException { 
    Map<String, Object> retMap = new HashMap<String, Object>(); 

    String email=(String) input.get("email"); 
    long id=(Long) input.get("userid"); 
    String password=(String) input.get("password"); 
    String rollid="1"; 
    User user = new User(); 
    user.setEmail(email); 
    user.setId(id); 
    user.setPassword(bCryptPasswordEncoder.encode(password)); 

    userRepository.save(user); 

    ResponseEntity<Map<String, Object>> retValue = new ResponseEntity<Map<String,Object>>(retMap, HttpStatus.OK); 
    return retValue; 
} 

===@RequestBody地圖<字符串,對象>輸入獲取int值

$scope.saveUserFunction = function(myVar) { 
    console.log($scope.edituserdetails.email); 
    console.log($scope.edituserdetails.email); 
    console.log($scope.edituserdetails.username); 
    console.log($scope.edituserdetails.password); 
    console.log($scope.edituserdetails.id); 

    console.log($scope.token); 
    //$scope.user = {}; 
    // calling our submit function. 


     $http({ 
      method : "POST", 
      url  : "/registrationuser", 
      data : { 
      "email"  : $scope.edituserdetails.email, 
      "username": $scope.edituserdetails.username, 
      "password" : $scope.edituserdetails.password, 
      "userid": $scope.edituserdetails.id 
      } 

      }) 
      .success(function(data) { 
       if (data.errors) { 

       } else { 
       // $scope.message = data.message; 
       } 
      }); 

}

});

獲取用戶ID的以下錯誤。爲什麼它是整數。我需要投射它以及長時間?

回答

0

你可以在春天休息直接使用你的實體,如:

@RequestBody User user 

之後的密碼,然後也可以被重置。

此外,返回值不應該是Map

return new ResponseEntity<User>(user, HttpStatus.OK); 
相關問題