我如何通过不是域类实例的控制器将参数传递到groovy服务器页面?
您将参数放入返回给 GSP 的模型对象映射中,例如:
def index = { def hobbies = ["basketball", "photography"]
render(view: "index", model: [name: "Maricel", hobbies: hobbies]) }
然后,您可以通过模型映射中使用的名称来获取这些值,例如:
My name is ${name} and my hobbies are:
<ul>
<g:each in="${hobbies}" var="hobby">
<li>${hobby}</li>
</g:each>
</ul>
应该显示以下内容:
My name is Maricel and my hobbies are:
- basketball
- photography
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)