开发者

How do you nest g:each tags in gsp?

Assume I have the following classes

class Genre {
    static hasMany=[author:Author]
}

class Author{

    static hasMany=[books:Books]
}


class Books{
       Author author 
开发者_如何学Go}

How do I go about printing this in the gsp using g:each tag?


If you want to display all books by author you could have something like

<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>

Cheers!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜