如何在 Grails 中分页?

How to paginate in Grails?

我是 grails 的新手,我正在尝试在我的应用程序中实现分页。 我已经按照文档中的示例进行操作,但似乎什么也没发生,它无法呈现页面导航按钮。这是示例代码:

def transaction = DataEntry.findAll() as List
    render(model: [transactions: transaction, total: transaction.count ], view: "/Transactions/verify")

然后在我看来我已经把这个:

<g:each var="transaction" in="${transactions}">
    <h1>${transaction.sendersName}</h1>
</g:each>

<g:paginate next="Forward"
            prev="Back"
            maxsteps="1" 
            controller="approvedTransaction"
            action="index" 
            total="${total}" />

任何帮助将不胜感激!

检查这个例子

域class:

class DataEntry{
    String sendersName
}

控制器:

class TransactionsController {
    def list() {
        [data: DataEntry.list(params), dataEntryCount: DataEntry.count()]
    }
}

分页代码:

<g:paginate controller="transactions" action="list" total="${dataEntryCount}" />

<g:paginate next="Forward" prev="Back"
            maxsteps="0" controller="transactions"
            action="list" total="${dataEntryCount}" />

详情请参考documentation