2016-07-31 29 views
0

我是AngularJS的新手,我試圖使用REST api URL獲取數據,並試圖將URL傳遞給angularjs並在HTML中顯示數據。但它顯示內部服務器錯誤。請找出錯誤的屏幕截圖和休息URL數據在AngularJS中傳遞的Java REST API URL不起作用

enter image description here

enter image description here

enter image description here

這裏是我的HTML,

<html ng-app="myApp" ng-controller="myCtrl"> 

<head> 

    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"> 
    </script> 
    <script> 
    var app = angular.module('myApp', []); 
    app.controller('myCtrl', function($scope, $http) { 
     $http({ 
     method: "GET", 
     url: "http://localhost:8080/WebApplication1/webresources/rest.employee/Show/1" 
     }).then(function mySucces(response) { 
     $scope.myWelcome = response.data; 
     }, function myError(response) { 
     $scope.myWelcome = response.statusText; 
     }); 
    }); 
    </script> 
</head> 

<body> 
    {{myWelcome}} 
</body> 

</html> 
+0

什麼樣的錯誤你是在瀏覽器調試器/開發工具的控制檯看到? –

+0

我已經包含了控制檯錯誤的另一個屏幕截圖... – JavaLearner1

+0

然後你應該檢查服務器端發生了什麼 –

回答

0

enter image description here

enter image description here

步驟1:右鍵點擊瀏覽器圖標,然後選擇物業菜單

步驟2:選擇快捷方式 Tab。然後在下面的目標文本框已經有一些路徑將在那裏。 例如: 「C:\ Program Files文件(x86)的\谷歌\鍍鉻\應用\的chrome.exe」

不要改變路徑添加的user-data-DIR =「C:/鍍鉻「--disable-web-security此文本在路徑的末尾。

示例: 「C:\程序文件(x86)\谷歌\鉻\應用\的chrome.exe」 的user-data-DIR = 「C:/鉻」 - 禁用網絡的安全

第三步:然後點擊OK按鈕