所以这是我的控制器中的 show() 方法,其中 InsitutionList 作为全局变量,但是当我想从 list.gsp 访问这个 InsitutionList 时,它没有呈现(也没有给出任何错误,如空值,从那里我相信我正在传递它成功)任何东西。还提到了下面的 gsp 片段。
def show(Long id){
def tacticalIndustryCodeInstance = TacticalIndustryCode.get(id);
def query = Institution.where { idParam ->
idInstitution == idParam
}
def institution = query.find(id)
if(!institution){
flash.message = message(code: 'default.not.found.message', args: [message(code: 'institution.label', default: 'Institution'), id])
redirect(action: "list")
return
}
institutionList.putAt(institution.getLongName(), tacticalIndustryCodeInstance)
if(!tacticalIndustryCodeInstance){
flash.message = message(code: 'default.not.found.message', args: [message(code: 'tacticalIndustryCode.label', default: 'TacticalIndustryCode'), id])
redirect(action: "list")
return
}
[tacticalIndustryCodeInstance: tacticalIndustryCodeInstance, institutionList: institutionList]
}
尝试了不同的东西,没有运气:
1)
<td><g:link action="show" id="${tacticalIndustryCodeInstance.id}">${fieldValue(bean: tacticalIndustryCodeInstance, field: "id")}</g:link></td>
<td>${fieldValue(bean: tacticalIndustryCodeInstance, field: "industrySector")}</td>
<td>${Institution.executeQuery("Select longName from Institution where idInstitution = :id?",[id : $(fieldValue(bean: tacticalIndustryCodeInstance, field: "id"))])}</td>
</tr>
</g:each>
2)像这样更简单也不起作用
<g:each in="${institutionList}" var="institutionListInstance">
<td>${fieldValue(bean: institutionList, field: "longName")}</td>
</g:each>
3)
<table id="tacticalIndustryCodeTable" class="center">
<thead>
<tr>
<g:sortableColumn property="id" title="${message(code: 'tacticalIndustryCode.id.label', default: 'Institution Id')}" />
<g:sortableColumn property="industrySector" title="${message(code: 'tacticalIndustryCode.industrySector.label', default: 'industrySector')}" />
<g:sortableColumn property="longName" title="${message(code: 'institution.longName.label', default: 'longName')}" />
</tr>
</thead>
<tbody>
<g:each in="${institutionList}" var="institutionListInstance">
<td>${institutionListInstance.key}</td>
<g:each in="${institutionListInstance.value}" var="item">
<td>${item.id}</td>
<td>${item.industrysector}</td>
</g:each>
</tbody>
</table>