AngularJS post方法不起作用

时间:2016-09-27 11:40:38

标签: java angularjs servlets

我经历了大量的堆栈溢出和谷歌的东西,我不知道哪里错误的网址每次都得到错误为404控制器文件

我的jsp是

<div id="signUp" class="signUp" >
            <form class="formCls" method="POST" ng-submit="createUser()">
                <input type="text" placeholder="Name" ng-model="signUp.name"><br> 
                <input type="email" placeholder="Email"  ng-model="signUp.email"><br> 
                <input type="date" placeholder="dateOfBirth" ng-model="signUp.dob"><br> 
                <input type="password" placeholder="Password" ng-model="signUp.password"><br>
                <input type="password" placeholder="Conform Password"><br> 
                <input type="submit" value="Login">&nbsp;&nbsp;&nbsp;&nbsp; 
                <input type="reset" value="Reset"><br><br>
                To Login <a href="" id="loginFromSignup">Click Here</a>
            </form>

        </div>

我的app.js是

    myApp.controller('myControler', function($scope, $http) {
     $scope.createUser = function() {
         alert("hai");
         console.log($scope.signUp);
        $http({
            method : 'POST',
            url : 'http://localhost:8080/travelBlog/src/com/bluewind/ccontroller/Signup',
            headers: {'Content-Type': 'application/json'},
             data : '$scope.signUp'
        }).success(function (data){
            console.log("I am done");
            $scope.myWelcome = data;
          });
    };
});

我的servlet程序是

@WebServlet("/Signup")
public class Signup extends HttpServlet {

/**
 * 
 */
private static final long serialVersionUID = 1L;

  @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
      System.out.println("I came to servlet");
       String memberName = request.getParameter("signUp.name");
       System.out.println(memberName);

    }

}

0 个答案:

没有答案