GRAILS
控制器
def beta() {
params.max = Math.min(params.max ?: 10, 100)
params.offset = Math.min(params.offset ?: 10, 100)
def l = Portfolio.findAllByPublished(true, params)
int total = Portfolio.countByPublished(true)
withFormat {
html {
[list:l, portfolioInstanceTotal: total]
}
json {
render l as JSON
}
}
}
GSP模板
<div class="pagination">
<g:paginate omitPrev="true" omitNext="true" controller="designer" action="beta" total="${portfolioInstanceTotal}" />
</div>
我还使用JQuery和freewall js将图像附加到网格中。我尝试将图像附加到分页,但是我在stacktrace上看到了错误。
谢谢!
答案 0 :(得分:0)
请求参数是字符串。所以params.offset
返回一个String。
使用String作为参数调用Math
方法会引发异常。
您应首先将String转换为int:
params.max = Math.min(params.max.toInteger() ?: 10, 100)
...