如何将数据从angularjs控制器传递和检索到struts操作

时间:2016-06-09 10:12:29

标签: angularjs struts2

Angular js控制器

var data = {"username" : $scope.username,"password" : $scope.password};

    $scope.sign = function($location, $window, $rootScope) {
        $http({
            method : 'POST',
            url : '/Newproject/getin.action',
            params : {value:data},
            headers : {
                'Content-Type' : 'application/x-www-form-urlencoded'
            }
        }).success(function(data) {

        });

struts.xml中(动作)

      <action name="getin" class="com.cibin.SignInAction">
        <result name="success" type="tiles">/welcome.home

            <param name="value">value</param></result>

        <result name="input">/index.jsp</result>
        <result name="error">/index.jsp</result>
        <result name="loginpage">/index.jsp</result>
</action>

SignInAction.java

public String execute() {

    String contactJsonData = request.getParameter("value");
    System.out.print(contactJsonData);

    return "success";
}

0 个答案:

没有答案