从控制器传递的gsp参数 [英] gsp parameter passing from controller
本文介绍了从控制器传递的gsp参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过不是域类的实例的控制器将参数传递到常规服务器页面?
解决方案
>您将参数放入返回给您的GSP的模型对象映射中,例如:
def index = {def hobbies = [ 篮球,摄影]
渲染(view:index,model:[name:Maricel,hobbies:hobbies])}
然后,通过您在模型映射中使用的名称来获取这些值,例如:
pre>
我的名字是$ {name},我的爱好是:
< ul>
< li> $ {hobby}< / li>
< / g:每个>
< / ul>
这应显示以下内容:
我的名字是Maricel,我的爱好是:
- 篮球
- 摄影
how can i pass parameters to a groovy server page via a controller that are not an instance of a domain class ?
解决方案
You put your parameters into the model object map returned to your GSP, for example:
def index = { def hobbies = ["basketball", "photography"]
render(view: "index", model: [name: "Maricel", hobbies: hobbies]) }
Then you get those values accessing them by the name you use in your model map, for example:
My name is ${name} and my hobbies are:
<ul>
<g:each in="${hobbies}" var="hobby">
<li>${hobby}</li>
</g:each>
</ul>
That should display the following:
My name is Maricel and my hobbies are:
- basketball
- photography
这篇关于从控制器传递的gsp参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文