Angularjs spring中使用angular HTTP将数据提取到网页 .........

Angularjs spring中使用angular HTTP将数据提取到网页 .........,angularjs,rest,Angularjs,Rest,我想在spring项目中借助angular将MySQL数据库中的数据显示到上面的… 最简单的方法是什么?我建议您: 在你看来: <table> <th> <tr>.........</tr> </th> </table> data.json将是一个url,您可以从中获取数据以显示在表中。看看plunkr添加的演示 你到底想说什么?:D@Kishore Kumar Naidu angularuse$http,你可以在tr中使

我想在spring项目中借助angular将MySQL数据库中的数据显示到上面的

最简单的方法是什么?

我建议您:

在你看来:

<table>
<th>
<tr>.........</tr>
</th>
</table>
data.json
将是一个url,您可以从中获取数据以显示在表中。看看plunkr添加的演示


你到底想说什么?:D@Kishore Kumar Naidu angularuse
$http
,你可以在
tr
中使用
ng repeat
属性,在
td/s
中,你可以用
{yourdata}
绑定数据,记住从后端返回
json
。假设我在MySQL中有一个名为user的表,其中包含所有用户名,我想在表中显示这些用户名。我将如何从MySQL获取这些user.json请指导我。或者,当我在HTTP参数中提供user.json时,它会自动获取json。@surendrakumar看到我添加的演示,这正是您要问的,但问题是您必须在json中返回用户名,如
[{“username”:“user1”…}]
,因此,从后端生成json取决于您。请看,您需要使用GSON JAR将ArrayList转换为json对象,您只需返回它,然后只需使用方法url替换
数据。json
。是的,我想知道如何从后端生成json这将对您有所帮助。
 <table ng-controller="MyCtrl"> <!--your ctrl-->
   <tr ng-repeat="item in items"><!--place the ng-repeat-->
     <td>{{item.name}}</td> <!--bind the data-->
   </tr>
 </table>
var app = angular.module('plunker', []); // most important to define angular module

app.controller('MyCtrl', function($scope, $http) { // controller def
  $http.get('data.json').
    success(function(data) { // ajax
       $scope.items = data; // update the items var in $scope here
    });
});