gpt4 book ai didi

mysql - 如何通过单击 grails 中的按钮(.Groovy Server Pages 页面)从 Mysql 数据库获取表的所有值/行?

转载 作者:行者123 更新时间:2023-11-29 07:11:58 25 4
gpt4 key购买 nike

如何将表中所有行的所有数据从 MySQL 数据库获取到我的 Groovy Server Pages(GSP) 页面?已经尝试过获取列表但没有成功。

def list(){
def student1 = Student.getAll(1,2,3)
[student:student1]
}

最佳答案

def list(){
[students: Student.list()]
}

在你的list.gsp中

<ul>
<g:each in="${students}" var="student">
<li>${student.id}</li> <!-- or other property -->
</g:each>
<ul>

关于mysql - 如何通过单击 grails 中的按钮(.Groovy Server Pages 页面)从 Mysql 数据库获取表的所有值/行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39361124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com