grails分页列表无法正常工作

grails分页列表无法正常工作,grails,pagination,Grails,Pagination,Iam使用grails在MyProjext中通过分页实现搜索功能。通过下面的代码,我可以看到max=5的第一个结果集,但是当我单击“next”时,它不会返回任何数据 下面是代码片段: 控制器代码: List <SearchCommand> empDetailsList = searchService.searchEmployee(searchCommand) def userlist = criteria.list(max:searchCommand.max, offset:sea

Iam使用grails在MyProjext中通过分页实现搜索功能。通过下面的代码,我可以看到max=5的第一个结果集,但是当我单击“next”时,它不会返回任何数据

下面是代码片段: 控制器代码:

List <SearchCommand> empDetailsList = searchService.searchEmployee(searchCommand)
def userlist = criteria.list(max:searchCommand.max, offset:searchCommand.offset){
        userProfiles {
            like ('firstName', "${searchCommand.firstName}%")   
            like ('lastName', "${searchCommand.lastName}%")
        }
        employees {
            like ('employeeNum', "${searchCommand.employeeNum}%")
            like ('payeNum', "${searchCommand.payeNum}%")
        }             
    }      
List <SearchCommand> searchCommandList = new ArrayList<SearchCommand>()   
for(userObject in userlist) {
    SearchCommand searchCommandObj = new SearchCommand()
    def user = userObject as SchemeUser
    UserProfile userprofile = UserProfile.findBySchemeUser(user)
    searchCommandObj.firstName =  userprofile.firstName
    searchCommandObj.lastName =  userprofile.lastName
    println "userprofile.firstName : " + userprofile.firstName
    Employee emp = Employee.findByUser(user)
    searchCommandObj.employeeNum =  emp.employeeNum
    searchCommandObj.payeNum =  emp.payeNum
    searchCommandList.add(searchCommandObj)
}
return searchCommandList
List-empDetailsList=searchService.searchEmployee(searchCommand)
服务代码:

List <SearchCommand> empDetailsList = searchService.searchEmployee(searchCommand)
def userlist = criteria.list(max:searchCommand.max, offset:searchCommand.offset){
        userProfiles {
            like ('firstName', "${searchCommand.firstName}%")   
            like ('lastName', "${searchCommand.lastName}%")
        }
        employees {
            like ('employeeNum', "${searchCommand.employeeNum}%")
            like ('payeNum', "${searchCommand.payeNum}%")
        }             
    }      
List <SearchCommand> searchCommandList = new ArrayList<SearchCommand>()   
for(userObject in userlist) {
    SearchCommand searchCommandObj = new SearchCommand()
    def user = userObject as SchemeUser
    UserProfile userprofile = UserProfile.findBySchemeUser(user)
    searchCommandObj.firstName =  userprofile.firstName
    searchCommandObj.lastName =  userprofile.lastName
    println "userprofile.firstName : " + userprofile.firstName
    Employee emp = Employee.findByUser(user)
    searchCommandObj.employeeNum =  emp.employeeNum
    searchCommandObj.payeNum =  emp.payeNum
    searchCommandList.add(searchCommandObj)
}
return searchCommandList
def userlist=criteria.list(max:searchCommand.max,offset:searchCommand.offset){
用户配置文件{
比如('firstName',“${searchCommand.firstName}%”)
类似('lastName',“${searchCommand.lastName}%”)
}
雇员{
比如('employeeNum',“${searchCommand.employeeNum}%”)
类似('payeNum',“${searchCommand.payeNum}%”)
}             
}      
List searchCommandList=newarraylist()
for(用户列表中的用户对象){
SearchCommand searchCommandObj=新建SearchCommand()
def user=userObject作为SchemeUser
UserProfile UserProfile=UserProfile.findBySchemeUser(用户)
searchCommandObj.firstName=userprofile.firstName
searchCommandObj.lastName=userprofile.lastName
println“userprofile.firstName:+userprofile.firstName
Employee emp=Employee.findByUser(用户)
searchCommandObj.employeeNum=emp.employeeNum
searchCommandObj.paynum=emp.paynum
searchCommandList.add(searchCommandObj)
}
返回搜索命令列表
Iam在gsp中使用empDetailsList进行分页


我需要解决什么问题,以便gsp在单击“下一步”时正确显示分页结果?

我认为缺少分页标记库的total参数。检查是否为此标记属性使用了正确的值

<g:paginate controller="ctrl" action="list" total="${totalValue}"/>

您还可以控制传递给控制器的最大值和偏移值。furhtermore我还可以控制为分页链接(1,2,…上一页,下一页,…)生成的最大和偏移量url参数