无法将ID从gsp传递到控制器 [英] Not able to pass the ID to the controller from gsp
问题描述
我想通过id =$ {training.id}传递给组织控制器,通过控制器中的confirm()函数。但是当我传递它时,它显示NULL结果。(id )我打印的是NULL。
I want to pass the id="${training.id}" to the Organization controller wiith the confirmed() function inside the controller.but when i am passing it,it is showing me the NULL result.The (id) i am printing is NULL.
gsp file
<g:each in="${trainingLists}" var="training">
<div class="card">
<div class="card-header">
<h3>Organization Name:</h3>${training.organization.orgName}</div>
<div class="card-body">
<h3>Organization Description:</h3>${training.organization.orgDesc}</div>
<div class="card-body">
<h3>Training Available:</h3>${training.name}</div>
<sec:ifNotLoggedIn>
<g:link controller="organization" action="notconfirmed">Apply</g:link>
</sec:ifNotLoggedIn>
<sec:ifLoggedIn>
<g:link action="confirmed" id="${training.id}">Apply</g:link>
</sec:ifLoggedIn>
</div>
<br>
</g:each>
Organization.controller
Organization.controller
def confirmed(){
def id = params.id
println(id)
}
推荐答案
您的gsp < g:link>
看起来不错。
Your gsp <g:link>
looks good.
请调试并检查 $ {training.id}
是否有有效的ID。
Please debug and check is ${training.id}
have valid id.
<g:link controller="organization" action="confirmed" id="${training.id}">Apply</g:link>
仍然会出现问题,然后检查临时硬编码id并检查
, p>
still getting issue then temporary hard-code id to and check for Example:
<g:link controller="organization" action="confirmed" id="2">Apply</g:link>
现在在地址栏中,您会像 localhost:8080 / organization / confirmed / 2
和控制器println也打印出2。
Now in address bar you will URL like localhost:8080/organization/confirmed/2
and controller println also print the 2.
您可以检查文档了解更多属性和选项
You can check documentation for more attributes and options
这篇关于无法将ID从gsp传递到控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!