2016-07-31 87 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按钮