我的控制器中有以下方法,用于列出患者实体:
def list(Integer max) {
params.max = Math.min(max ?: 10, 100)
def roles = springSecurityService.getPrincipal().getAuthorities()
if(roles == 'ROLE_USER')
{
[patientInstanceList: Patient.findAllBySecUser(springSecurityService.getCurrentUser()), patientInstanceTotal: Patient.count()]
}
else if(roles == 'ROLE_ADMIN' || roles == 'ROLE_MANAGER')
{
[patientInstanceList: Patient.list(params), patientInstanceTotal: Patient.count()]
}
}
如果我执行此方法,我有例外
Tag [paginate] is missing required attribute [total]
但是,如果我使用以下
def list(Integer max) {
params.max = Math.min(max ?: 10, 100)
[patientInstanceList: Patient.list(params), patientInstanceTotal: Patient.count()]
}
}
一切正常。我看到创建的所有 Patient 实例。我只想这样,根据登录用户的角色,我可以看到创建的所有实体的一部分。为什么会引发此异常?
我在这里发现了Grails pagination tag error类似的东西,但没有给出好的答案