Javascript 从mongodb获取列表
我对javascript一无所知。我想从mongodb获取对象列表,并在表中显示它们。 这是我的代码: 订单资源Javascript 从mongodb获取列表,javascript,mongodb,rest,Javascript,Mongodb,Rest,我对javascript一无所知。我想从mongodb获取对象列表,并在表中显示它们。 这是我的代码: 订单资源 @Path("order/{size}") @GET public Object showOrder(@PathParam("size") String size){ List<DBObject> OrderList = null; DBCollection collection = datastore.getDB().getCollection("Ord
@Path("order/{size}")
@GET
public Object showOrder(@PathParam("size") String size){
List<DBObject> OrderList = null;
DBCollection collection = datastore.getDB().getCollection("Order");
DBCursor OrderCursor = collection.find(QueryBuilder.start("size").is(size).get());
OrderList = OrderCursor.toArray();
if (OrderCursor == null) {
throw new WebApplicationException(404);
}
GenericEntity<List<DBObject>> entity = new GenericEntity<List<DBObject>>(OrderList) {};
return Response.ok(entity).build();
}
order.html
<div ng-controller="FindOrderController" class="container">
<table>
<tr>
<th>Drinker</th>
</tr>
<tr ng-repeat="OrderBySize in orders">
<th>{{OrderBySize.drinker}}</th>
</tr>
</table>
饮酒者
{{OrderBySize.drinker}}
但是我的桌子还是空的。怎么了?最可能的答案是没有实际数据。到目前为止,您调试了什么?您是否至少添加了大量日志以查看服务器端有哪些可用数据以及客户端接收到哪些数据?System.out.println()/console.log语句等?浏览器的网络日志功能还可以帮助您查看发送的内容和接收的内容。我的响应包含18个元素,但随后出现问题。谢谢你的建议,我正在努力找出问题所在。
<div ng-controller="FindOrderController" class="container">
<table>
<tr>
<th>Drinker</th>
</tr>
<tr ng-repeat="OrderBySize in orders">
<th>{{OrderBySize.drinker}}</th>
</tr>
</table>