grails - 用相同的键附加到查询字符串

标签 grails query-string

我正在尝试使用相同的键将某些部分添加到查询字符串中。

我有一个类似http://server.com/search/result?query=hello的网址,带有一些应在查询字符串中添加collaborator的控件。

这样做是这样的:

<g:link action="result" params="${params + ['collaborator': collaborator.id]}">${collaborator.name}</g:link>

返回:http://server.com/search/?query=hello&collaborator=<id>

这一切都很好,但是有可能选择更多的合作者。如何在查询中附加另一个&collaborator=<id>

我尝试了${params + [params.collaborator + collaborator.id]}等各种方法,但这仅将它们放在一个字符串中。

最佳答案

试试这个:

gsp:

<g:link action="result" params="${params + ['collaborator': params.list('collaborator') + [collaborator.id]]}">${collaborator.name}</g:link>

操作:
List collaboratorList = params.list('collaborator')
//Your operations on this list

关于grails - 用相同的键附加到查询字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25360415/

相关文章:

javascript - 从 &lt;script&gt; 链接获取查询字符串的安全风险?

ajax - Grails remoteLink:整个页面已加载以响应

grails - Grails获取 Controller View

next.js - 如何从 Next.js 中的 URL 获取(查询字符串)参数?

javascript - 如何在 JavaScript 中拆分数组的查询字符串

.htaccess - 如何通过基于 URL 查询字符串的 .htaccess 文件设置 X-Robots-Tag HTTP header

c# - QueryString 将 %E1 转换为 %ufffd

grails - 带有Spring Security Core的Grails仅允许所有者在GSP中进行更新

grails - 如何更改 GRAILS GSP fieldValue 格式化整数的方式?

在 grails 应用程序中自定义 ehcache.xml 后抛出异常