templates - 如何根据传递的模型参数值来呈现模板值?

标签 templates grails model render gsp

我想在一页上呈现相同的模板,该模板应根据参数值(3或4)显示该值。
View 是-

 <td >
<g:render template="gdxqStatusTemplate" model="[param:3]" /> </td>
</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td >
<g:render template="gdxqStatusTemplate" model="[param:4]" /> </td>
</td>

Controller 具有-
 [ total3:totalValue3,total4:totalValue4]

如何在模板代码中显示合计的适当值-
<table >
    <tr ><td class="InputText" nowrap><b>   MessageQ Status,/td>

<tr> <td class="NoLight" nowrap>Total MessageQ : ${total+params}***/* IT SHOWS "total4" NOT THE VALUE.*/***
</td></tr>
<tr height=30></tr>
</table>

最佳答案

您必须更改:

 <g:render template="gdxqStatusTemplate" model="[param:3]" />
通过
 <g:render template="gdxqStatusTemplate" bean="${total3}" />
并在模板中替换:
 <td class="NoLight" nowrap>Total MessageQ : ${total+params}</td>
创建人:
 <td class="NoLight" nowrap>Total MessageQ : ${it}</td>
对于文档检查:http://grails.org/doc/2.0.x/ref/Tags/render.html

关于templates - 如何根据传递的模型参数值来呈现模板值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10033453/

相关文章:

ruby-on-rails - 我需要手动为我的外键字段添加索引还是 Rails 自动添加索引?

model-view-controller - 在MVC,MVP和MVVM中,模型可以是实体的集合吗?

c++ - 类型命名迭代器不是类型

grails - 如何将Google Web字体CSS添加到Grails资源

grails - 如何将Grails Controller 连接到 View ?

java - 保存对象时出错 : No Hibernate Session bound

python - Django 分层模型列表

c++ - 比较两个不同的枚举时,是否有避免警告的正确方法?

templates - 为什么在 C++0x 中,编译器选择通用移动赋值而不是特定移动赋值?

C++ 为什么 'note: see reference to class template instantiation being compiled'