Grails - 将参数添加到 params 映射
我想向我的 params
映射添加一个参数,并将其余参数绑定在链接中。目前,我仅按如下方式绑定 params
:
<g:link class="email" controller="administrator" action="test" params="${params}">Link text</g:link>
How can I add aparameter to the params
map ?
预先感谢您的帮助。 问候,
编辑:
好的,我找到了一种方法。
params="${params + ['forwardURI': request.forwardURI]}"
我不知道是否还有其他类似 Grails 的方法可以做到这一点。如果有的话,我有义务学习它;)
I would like to add a single parameter to my params
map, and bind the rest in a link. At the moment, I only bind the params
classically as follows:
<g:link class="email" controller="administrator" action="test" params="${params}">Link text</g:link>
How could I add a parameter to the params
map ?
Thank you in advance for you help.
Regards,
EDIT:
Ok, I have find a way to do it.
params="${params + ['forwardURI': request.forwardURI]}"
I do not know if there is any more Grails-like way to do it. If there is one, I would be obliged to learn it ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您必须重复执行此操作,您可以使用您在
g:link
包装标签库中发布的答案,因为标签库可以访问params
和请求
。在 gsp 中:
如果您想将标签与 gsp 中您自己的自定义参数映射一起使用,您还可以在标签库中使用以下内容:
If you have to do this repeatedly, you could use the answer you've posted in a
g:link
wrapper Tag Library, as Tag Libraries have access toparams
andrequest
.And in the gsp:
If you want to use the tag with your own custom parameter map from the gsp, you can also use the following in the Tag Library: