angular 发送ajax

  在使用angular发送ajax的时候get和post一样的,就是method改一下。

       ajax的js:

 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>

  后台接收:

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:

   要是遇到

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

   这种错误的话,应该是参数传入的格式有问题,接受不到造成的。

---不要装作很努力
原文地址:https://www.cnblogs.com/goblinn/p/9340749.html