简体   繁体   English

grails分页标记禁止访问方法

[英]grails pagination tag don't access method

I'm newbie to grails and I've tried to use the grails pagination Tag found here link text 我是grails的新手,我尝试使用在此处找到的grails分页标记链接文本
and when i tried to use it like he says like the this Controller : 当我尝试使用它时,就像他说的那样,这个控制器:

 def pageslist = {
 [pages: Page.list(params)]
}

view 视图

 < g:paginate next="Forward" prev="Back" maxsteps="5" controller="story" action="pageslist" total="${story.pages.count()}" />

it gives me nothing at all and the debugger never enter the controller method.. what is the problem and is there any other way for paginating in server side way 它什么也没有给我,并且调试器从不进入控制器方法..这是什么问题,还有没有其他方法可以在服务器端进行分页

You should use as Colin sugested last, ${Page.count()} and import Page into your gsp: 您应该使用Colin最后建议的${Page.count()}并将Page导入到您的gsp中:

<% import pa.ck.age.Page %>

or you can add another param to the model returned to the view: 或者,您可以向返回到视图的模型添加另一个参数:

def pageslist = {
   [pages: Page.list(params), total: Page.count()]
}

Try: 尝试:

<g:paginate next="Forward" prev="Back" maxsteps="5" controller="story" 
            action="pageslist" total="${pages.count()}" />

Because you've returned a map [pages: Page.list(params)] as the model from your controller, you will be able to access the variable pages from your view. 因为您已经从控制器返回了地图[pages: Page.list(params)]作为模型,所以您将能够从视图访问变量pages

Edit: 编辑:

You need to get the total count of Pages that you want to paginate through. 您需要获取要分页的页面总数。 Either use total="${Page.count()} " or add another variable to your model. 使用total="${Page.count()} ”或向模型添加另一个变量。

see the documentation on the Paginate tag for more. 有关更多信息,请参见分页标签上文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM