Grails MongoDB-如何在gsp页面上打印_id
我想打印mongo对象中存在的_id${oid}。当我打印整个对象时,我可以在对象中看到它,但当我尝试在gsp页面中引用它时,它无法访问它。 我不明白为什么 这是我的控制器方法Grails MongoDB-如何在gsp页面上打印_id,mongodb,grails,gorm,gsp,Mongodb,Grails,Gorm,Gsp,我想打印mongo对象中存在的_id${oid}。当我打印整个对象时,我可以在对象中看到它,但当我尝试在gsp页面中引用它时,它无法访问它。 我不明白为什么 这是我的控制器方法 def index_mod(Integer max) { MongoClient mongoClient = new MongoClient("localhost", 27017) DB chloroKB = mongoClient.getDB("ChloroKB"); log.d
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>
有人有主意吗?
提前感谢${list.id}不起作用,${list.\u id}会认为这只是一个输入错误,谢谢回复!生成的html是什么样子的?