我在angularjs中使用$ http调用一个java,但我在Chrome中收到此错误:
XMLHttpRequest无法加载http://192.168.1.104:8080/etts/Abilityscore?userid=1。 No' Access-Control-Allow-Origin'标头出现在请求的资源上。起源' http://localhost:8080'因此不允许访问。
我的代码是:
var countryApp = angular.module('countryApp', []);
countryApp.controller('CountryCtrl', function ($scope, $http){
alert("eee")
$http.get('http://192.168.1.104:8080/etts/Abilityscore?userid=1
').success(function(data) {
$scope.countries = data;
var sum = 0;
var tval = 0;
for(var i = 0; i < data.length; i++){
sum += parseInt(data[i]['getval'], 10);
tval += parseInt(data[i]['totalval'], 10);
}