我想在我的mongo对象中打印_id($ {oid}。当我打印整个对象时,我可以在对象中看到它,但是当我尝试在我的gsp页面中引用它时,它无法访问它。 我不明白为什么?
这是我的控制器方法
def index_mod(Integer max) {
MongoClient mongoClient = new MongoClient("localhost", 27017)
DB chloroKB = mongoClient.getDB("ChloroKB");
log.debug("DB : " + chloroKB)
def crossref = chloroKB.getCollection("CrossReference_URL")
log.debug("crossref : " + crossref)
def crossrefList = new ArrayList<CrossReference_URL>()
def crossrefCount = 0
DBCursor cursor = crossref.find()
try {
while(cursor.hasNext()) {
def nextCrossRef = cursor.next()
log.debug(crossrefCount + " - " + nextCrossRef)
crossrefList.add(nextCrossRef)
crossrefCount++
}
} finally {
cursor.close();
}
log.debug("list CrossRef : " + crossrefList)
params.max = Math.min(max ?: 10, 100)
model:[count: crossrefCount, crossReferenceList: crossrefList]//CrossReference_URL.list(params)]
}
这是我想在我的gsp页面中打印它的表:
<table>
<!-- SBO - test what is in the crossReference_URLInstanceList -->
<tr><th>crossReference_URLInstanceList : ${crossReferenceList}</th></tr>
<thead>
<tr>
<g:sortableColumn property="crossref_source" title="${message(code: 'crossReference_URL.id.label', default: 'Id')}" />
<g:sortableColumn property="crossref_source" title="${message(code: 'crossReference_URL.crossref_source.label', default: 'Crossrefsource')}" />
<g:sortableColumn property="crossref_url" title="${message(code: 'crossReference_URL.crossref_url.label', default: 'Crossrefurl')}" />
</tr>
</thead>
<tbody>
<g:each in="${crossReferenceList}" status="i" var="list">
<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
<td>${list.id}</td>
<td><g:link action="show" id="${list._id}">${list.crossref_source}</g:link></td>
<td>${list.crossref_url}</td>
</tr>
</g:each>
</tbody>
</table>
有人有想法吗? 提前致谢