如何从控制器获取列表的值到gsp
how to get values of list from controller to gsp
一直在尝试从不同的过程中获取值,但没有成功。
控制器:
def list(){
Student stud = new Student()
def listStudents = stud.executeQuery("from Student")
listStudents.each{ lisStud->
println "email = ${lisStud.email}"
render view:"/layouts/listOFstudents"
}
Table:
<table>
<tr>
<g:each in="${lisStud}">
<td>${lisStud.email}</td>
</g:each>
class HelloController {
def index() {
def list = []
list << new Person(firstName: 'John', lastName:'Doe', age:50)
list << new Person(firstName: 'Jane', lastName:'Smith', age:45)
list << new Person(firstName: 'Sam', lastName:'Robinson', age:47)
[ list:list ]
}
}
只是不要将页面渲染到任何其他页面然后索引
控制器:
def list(){
Student stud = new Student()
def listStudents = stud.executeQuery("from Student")
def displayStudentList = []
listStudents.each{ lisStud->
println "email = ${lisStud.email}"
displayStudentList += it
}
[displayStudentList : displayStudentList]
}
观看次数:
list.gsp
<g:each in="${displayStudentList}" var="lisStud">
<td>${lisStud.email}</td>
</g:each>
一直在尝试从不同的过程中获取值,但没有成功。
控制器:
def list(){
Student stud = new Student()
def listStudents = stud.executeQuery("from Student")
listStudents.each{ lisStud->
println "email = ${lisStud.email}"
render view:"/layouts/listOFstudents"
}
Table:
<table>
<tr>
<g:each in="${lisStud}">
<td>${lisStud.email}</td>
</g:each>
class HelloController {
def index() {
def list = []
list << new Person(firstName: 'John', lastName:'Doe', age:50)
list << new Person(firstName: 'Jane', lastName:'Smith', age:45)
list << new Person(firstName: 'Sam', lastName:'Robinson', age:47)
[ list:list ]
}
}
只是不要将页面渲染到任何其他页面然后索引
控制器:
def list(){
Student stud = new Student()
def listStudents = stud.executeQuery("from Student")
def displayStudentList = []
listStudents.each{ lisStud->
println "email = ${lisStud.email}"
displayStudentList += it
}
[displayStudentList : displayStudentList]
}
观看次数:
list.gsp
<g:each in="${displayStudentList}" var="lisStud">
<td>${lisStud.email}</td>
</g:each>