我在通过 g:render 将数据传递到另一个 View (包含在 printme.gsp 中)时遇到问题
printme.gsp:
<h1>abc</h1>
${input1Instance?.number} <!-- Here I can see the right value -->
<g:render contextPath="../input1" template="form"/>
input1/_form.gsp:
<!-- Here there is no value set -->
<g:textArea maxlength="1000" name="number" value="${input1Instance?.number}"/>
如何将对象从 printme.gsp 传递到 input/_form.gsp?
谢谢。
最佳答案
您必须显式地将数据作为模型传递:
<g:render contextPath="../input1" template="form" model="[input1Instance:input1Instance]"/>
然后您可以从模板访问它
关于Grails:g:渲染 channel 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16802340/