grails - 如何通过GSP内部的g:each调用Controler Action?

标签 grails gsp

我有一个名为 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/

相关文章:

tomcat - 服务器整夜闲置后出现 GSP 渲染问题

javascript - 为什么它无法访问Javascript函数?

grails - 如何在Grails项目中包含Groovy

grails - Grails:无法删除或更新父行:外键约束失败

grails - 在单个附加程序上使用多个记录器

grails - 如何将此SQL查询转换为Grails或GORM查询

hibernate - grails 在 hibernate 中映射非域类的正确方法

grails - 了解Grails模板中下划线的目的

grails - GSP 页面中的递归

grails - <g:each>的问题