angular 發送ajax

  在使用angular發送ajax的時候get和post同樣的,就是method改一下。ajax

       ajax的js:json

 1      <script>
 2        var app = angular.module('emialVerfiy',[]);  3        app.controller('ev',function($scope,$http){  4            $scope.send = function(){  5                
 6  $http({  7                    method:'get',  8                    url:'../mailVerfiy/verfiy',  9                    contentType:'application/json;charset=UTF-8', 10  params : { 11                        'mial' : $scope.show 12  } 13                }).then(function successCallback (rs){ 14                    $scope.show = rs.data; 15  }); 16  } 17  }); 18     </script>

 

  後臺接收:app

1     @RequestMapping(value="/verfiy", method=RequestMethod.GET) 2  @ResponseBody 3     public String verfiy(@RequestParam(value="mial", required=true) String mail) 4  { 5  mailVerService.sendMail(mail); 6         return "發送成功,請去郵箱驗證。"; 7     }

 

  ps:post

   要是遇到ui

     Status Code:400 Required String parameter 'mail' is not present 

   這種錯誤的話,應該是參數傳入的格式有問題,接受不到形成的。url

相關文章
相關標籤/搜索