2017-05-10 7 views
0

は私angularjsコードはどのようにここで

$http({ 
       method : "POST", 
       url : '/jobseeker', 
       data : { 
        "email" : $scope.userdata.uemail, 
        "firstname" : $scope.userdata.fname, 
        "lastname" : $scope.userdata.lname, 
        "password" : $scope.userdata.upassword 
       } 
      }).success(function(data) { 
       console.log(data); 
       //state.go(to verification page for job seeker 
      }) 

であり、ここで

@RequestMapping(value = "/jobseeker", method = RequestMethod.POST) 
    public ResponseEntity signUp(@RequestParam("email") String email, 
           @RequestParam("firstname") String firstname, 
           @RequestParam("lastname") String lastname, 
           @RequestParam("password") String password) { ....} 

私は400不正な要求エラーを取得しています、私の残りのコントローラのマッピングである角度JSを使用して、残りのコントローラを春にポスト要求データを送信しますパラメータの電子メールがないことを示す

私のコードに次のヘッダを追加しても、同じエラーが表示されます。

headers: { 
        'Content-Type': 'application/x-www-form-urlencoded' 
       } 
+0

に同じですあなたは郵便配達を通じて確認することができますことを確認? –

+0

郵便配達員はうまく動作します。 – Neeraj

+0

郵便配達員のcontent-typeヘッダーをapplication/jsonに設定すると、同じエラーが返されます – Neeraj

答えて

0

この問題を修正してもAngularJSからPOSTを行う標準的な方法を投稿しようとしていますが、それ以外の方法はほとんどありません。

AngularJSでは、ControllerへのPOST呼び出しを保持する関数です。

$scope.httpFunction = function() { 
    var data = new FormData(); 
    data.append('email', $scope.userdata.uemail); 
    data.append('firstname', $scope.userdata.fname); 
    // Append as many parameters as needed 
    $http.post('jobseeker', data, { 
     withCredentials : false, 
     transformRequest : angular.identity, 
     headers : { 
       'Content-Type' : undefined 
     } 
    }).then(function(response){ 
     // ANything you wanted to do with response 
    }) 
} 

必ずパラメータの数が一致しているとのparamの名前は角とコントローラ