JAVA 中对List分页

//查询的所有数据
 List userList = userDao.createLambdaQuery()
                .andEq(User::getPhone, Query.filterEmpty(user.getPhone()))
                .andEq(User::getName, Query.filterEmpty(user.getName()))
                .andEq(User::getType,"3")
                .select();

        List users = new ArrayList<>();//装分页的list
        int currIdx = (pageNo > 1 ? (pageNo - 1) * 20 : 0);
        if (userList.size() > 0) {
            for (int i = 0; i < 10 && i < userList.size() - currIdx; i++) { 
                User active = userList.get(currIdx + i);
                users.add(active);
            }
        }

 

你可能感兴趣的:(java基础)