Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有以下课程
class Genre { static hasMany=[author:Author] } class Author{ static hasMany=[books:Books] } class Books{ Author author }
如何使用 g:each 标签在 gsp 中打印此内容?
如果你想按作者显示所有书籍,你可以有类似的东西
<g:each var="author" in="${Author.list()}"> <p>Author: ${author.fullName}</p> <ul> <g:each var="book" in="${author.books}"> <li>${book.title}</li> </g:each> </ul> </g:each>
干杯!