【发布时间】:2016-03-03 21:44:48
【问题描述】:
我有一个 AngularJS 框架的控制器。我使用 Http Post Request 将数组发送到服务器。如何在java方法中获取这个数组?
这是我的控制器
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
var indici = new Array();
indici.push(1);
indici.push(2);
$http.post("http://localhost:8080/SistemiDistribuiti/rest/Point/Trovati", indici, {
headers: { 'Content-Type': 'application/json' }
}).success(function(receivedData, status) {
$scope.someData = receivedData;
});
这是我的 java 类,但我不知道如何获取我的数组。
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.POST;
import javax.ws.rs.Consumes;
@Path("Point")
public class PointService {
@POST
@Path("Trovati")
@Consumes(MediaType.APPLICATION_JSON)
public void RetrieveData() {
//how print my array?
}
【问题讨论】:
-
如果您的问题是在服务器端检索数据,那么请更新您的客户端代码以实际发送内容。
-
我的问题是我的控制器中有一个数组(indici)。我想将此数组发送到服务器端(我使用tomcat),但我不知道http请求是否正确e以及如何在我的java代码中检索此数组。
标签: java arrays angularjs rest httprequest