【发布时间】:2015-04-16 12:08:14
【问题描述】:
我是 Grails 的新手,我尝试使用文档中的分页标签来显示特定数据。
分页显示在我的页面上,但是当我滑过它们时,它会在每个页面上显示我的所有数据,我希望每页仅显示总和中的 10 个项目。
这是我的控制器
class HomeController {
def actions() {
params.max = Math.min(params.max ? params.int('max') : 10, 100)
def articleActionOpera = newSuggestedShoppingItemsService.getNewSuggestedShoppingItems()
return [articles: articleActionOpera, actionTotal: articleActionOpera.size(), params:params]
}
}
这是我的服务
class NewSuggestedShoppingItemsService {
def operaOpusDbConnectorService
def getNewSuggestedShoppingItems() {
def returnRows = null
def sqlInstance = operaOpusDbConnectorService.openOperaOpusConnection()
try {
def sqlQuery = "SELECT passW, ArtName, Descript FROM dbo.fnWS_Newarticles()"
returnRows = sqlInstance.rows(sqlQuery)
return returnRows
}
catch(Exception ex) {
log.error("Fail, item are not shown.")
throw new Exception (ex)
}
}
}
还有我的 .gsp
...
<div id="paging">
<g:paginate total="${actionTotal}" />
</div>
【问题讨论】:
标签: grails pagination