嗨,我正在尝试使用groovy totalCount
获取列表的总计数,但是它抛出:
Exception evaluating property 'totalCount' for java.util.ArrayList,
Reason: groovy.lang.MissingPropertyException: No such property: totalCount
无论如何,我可以使用groovy
totalCount
而不是.size
获得总数吗?
最佳答案
在Grails中进行条件查询时,如果您使用分页参数(totalCount
和offset
)调用查询,则返回的列表只会提供max
。
params.max = params.max ?: 10
def resultWithTotalCount = MyDomain.createCriteria().list(params) {
// ...
}
没有分页的纯
list
调用将返回不具有totalCount
属性的非页面列表def resultWithoutTotalCount = MyDomain.createCriteria().list {
// ...
}
关于grails - Groovy totalCount与大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22597907/