我有一个名为 Student 的Domain类。它包含一些变量,例如 student_name,student_address,student_class 。实际上,我想按 student_class 的顺序显示学生详细信息。
我有一个名为list.gsp的GSP页面。
list.gsp:
<g:each in="${std}" status="v" var="stdInstance"> //All Class eg:1..10.
<h3>${stdInstance.std_class}</h3>
//Innerloop
//here i want to display students details depending on the value of stdInstance.std_class.
</g:each>
我想知道如何通过内部g:each和传递的参数来调用 Controller Action 。
最佳答案
在我的项目中,使用以下命令在需要时在我的GSP页面中包含一个登录部分:
<g:include controller="user" action="login"/>
其中controller是 Controller 名称,而action是 Controller 中的方法。您可以在此标记中使用
params="..."
属性来传递参数。我相信您可以根据自己的情况做同样的事情。例如。<g:include controller="user" action="login" params="..."/>
关于grails - 如何通过GSP内部的g:each调用Controler Action?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11645349/