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

相关文章
相关标签/搜索