Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在后端将对象传递给get方法和spring rest控制器时发生Angularjs错误_Javascript_Json_Angularjs_Ajax_Spring Mvc - Fatal编程技术网

Javascript 在后端将对象传递给get方法和spring rest控制器时发生Angularjs错误

Javascript 在后端将对象传递给get方法和spring rest控制器时发生Angularjs错误,javascript,json,angularjs,ajax,spring-mvc,Javascript,Json,Angularjs,Ajax,Spring Mvc,我试图为rest服务器创建注册表单并传递数据以进行do注册,但我只收到了这个错误。js:11607 SyntaxError:Unexpected token o 控制器: $scope.signIn = function(){ console.log($scope.ruser); // Object {username: "test@email.com", password: "password"} $http.get('p/registration', $scope.rus

我试图为rest服务器创建注册表单并传递数据以进行do注册,但我只收到了这个错误。js:11607 SyntaxError:Unexpected token o

控制器:

$scope.signIn = function(){
    console.log($scope.ruser); // Object {username: "test@email.com",   password: "password"}
    $http.get('p/registration', $scope.ruser).success(function(data) {

    });
}
 @RequestMapping("/p/registration")
 public String user(com.app.objects.users.User user) {
    System.out.println(user.getUsername()+" "+user.getPassword()); //print: null null :{
    return "ok";
}
弹簧座控制器:

$scope.signIn = function(){
    console.log($scope.ruser); // Object {username: "test@email.com",   password: "password"}
    $http.get('p/registration', $scope.ruser).success(function(data) {

    });
}
 @RequestMapping("/p/registration")
 public String user(com.app.objects.users.User user) {
    System.out.println(user.getUsername()+" "+user.getPassword()); //print: null null :{
    return "ok";
}

respose中的JSON格式无效?谢谢,我的服务器响应是单字符串ok。然后应该是JSON格式。如果NodeJS使用JSON.stringify,如果PHPI在服务器端使用java-spring-rest控制器,则使用JSON_编码。你什么时候得到这个方法?defore发送还是响应?