0

我将 Play Framework 与 MongoDB 结合使用。下面的视图有一个循环遍历我的集合并显示所有文档,但是,无论如何,是否只能访问 DBObject 中的特定字段,或者完全消除字段名称以进行格式化?目前的输出大致如下:

{ "_id" : { "$oid" : "548f61d97ff5d9996cf90c44"} , "reference" : "123" , "job_type" : 6months, "job_title" : "developer" , "company" : "Oracle"}

控制器:

public static Result find() {
List<DBObject> results = MongoController.find(MongoController.getLocalConnection("test"), "jobs");
if (results == null) { 
    redirect("/");
}

return ok(find_job.render(results));
}

我访问视图中的列表:

@(results : List[com.mongodb.DBObject])
@main("Job Listings") {

<table>
@for(result <- results) {
<tr>
    <td>@result.???</td>
</tr>
}
</table>
}
4

0 回答 0