grails g:链接传递参数

发布于 2024-11-09 06:52:52 字数 575 浏览 0 评论 0原文

我有这样的事情:

<g:each in="${temp}">

  <li>Date: ${it.dateParticipated}, <br>Role: ${it.role}, <br>Acceptence: ${it.accepted}, <br>
  <g:link controller="conference" action="participated" id="${it.conference.id}">
     Conference: </g:link>${it.conference},<br>
Role: ${it.role}, <br>Status: ${it.status}</li><br>

  <br>
</g:each>

我想做的是,当我单击“会议”时,将加载具有“参与”方法的控制器“会议”​​,并传递参数“it.conference”。我如何在 g:link 标记中传递此参数?

我需要这个,因为当我单击“会议”一词时,其他页面会加载会议详细信息并传递 id。

I have something like this:

<g:each in="${temp}">

  <li>Date: ${it.dateParticipated}, <br>Role: ${it.role}, <br>Acceptence: ${it.accepted}, <br>
  <g:link controller="conference" action="participated" id="${it.conference.id}">
     Conference: </g:link>${it.conference},<br>
Role: ${it.role}, <br>Status: ${it.status}</li><br>

  <br>
</g:each>

What i want to do is, when i click on 'Conference', the controller 'conference' with the method 'participated' is loaded, and the params 'it.conference' is passed. How can i pass this params in the g:link tag ?

I need this because, when i click in the 'conference' word, other page is loaded with the conference details with the id passed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜司空 2024-11-16 06:52:52

使用 params 属性传入参数映射:

<g:link action="/conference/participated" id="${it.conference.id}" params="[foo: 'bar', bar: 'foo']">My Link!</g:link>

有关更多示例,请参阅文档

Use the params attribute to pass in a map of parameters:

<g:link action="/conference/participated" id="${it.conference.id}" params="[foo: 'bar', bar: 'foo']">My Link!</g:link>

See the documentation for more examples.

幽蝶幻影 2024-11-16 06:52:52

您需要用 ${ } 包装整个参数,而不是包装要单独传递的每个变量。

<g:each in="${temp}">

  <li>Date: ${it.dateParticipated}, <br>Role: ${it.role}, <br>Acceptence: ${it.accepted}, <br>
  <g:link controller="conference" action="participated" params="${[id: it.conference.id, role: it.role, status: it.status]}">
     Conference: </g:link>

  <br>
</g:each>

You need to wrap your entire params with ${ }, instead of wrapping every variable that you want to pass separately.

<g:each in="${temp}">

  <li>Date: ${it.dateParticipated}, <br>Role: ${it.role}, <br>Acceptence: ${it.accepted}, <br>
  <g:link controller="conference" action="participated" params="${[id: it.conference.id, role: it.role, status: it.status]}">
     Conference: </g:link>

  <br>
</g:each>
╄→承喏 2024-11-16 06:52:52
params="[customerId: customer.id]"
params="[customerId: customer.id]"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文