从AngularJS控制器到Spring控制器的POST请求

时间:2017-09-20 11:11:14

标签: java angularjs spring

我发布了部分代码,因为它很多,但我想要做的是点击按钮"删除",从&#发送当前值34;附加信息"使用POST请求从我的typescript控制器div到java控制器。我的代码:

controlbarView.html

                

  <div class="perspectives">
     <div class="button" data-color="black">
        <button ng-click="perspectivesMode()"> EDIT MODE </button>
     </div>
     <div>
        <button ng-click="removeElement()"> REMOVE CURRENT </button>
     </div>
  </div>

  <div class="settings">

     <div class="extensions" style="height: 50px; width: 400px;" ng-repeat="ext in extensions track by $index" ng-if="$last">
        {{ext}}
     </div>

     <div class="extensionsNavi" style="height: 50px; width: 400px;" ng-repeat="ext in extensionsNavi track by $index" ng-if="$last">
        {{ext}}
     </div>

controlbarViewController.ts

 //for Shortcuts page - don't navigate to shortcuts page on click.
         $scope.perspectivesMode = function(){
           console.log("We're in perspectives mode");
           perspectivesService.setProperty(true);
           //console.log(navigationTreeService.getExtensions);
         };
         //Show extensions from shortcuts page
         $scope.extensions = perspectivesService.getExtension();
         //Show extensions from main pages
         $scope.extensionsNavi = navigationTreeService.getExtensions();

         //on click - add extension to file with extensions to remove
         $scope.removeElement = function(){
            var removeExt = $scope.extensions;
            $http({
               method: 'POST',
               url: 'remove',
               params: { removeExt: removeExt
                        }
            });
         };

extensionsController.java

@RequestMapping(value="/remove", method = Request.POST)

   public String getExtensionToRemove(){
      @RequestParam(value = "removeExt", required=false);
      return ext;
   }

如何修改我的java控制器以便获取并返回removeExt然后在另一个java类中使用它?

0 个答案:

没有答案