对list分页

/**
* 根据索引对源list进行截取并返回新的list,如果pageSize和pageNum任意一个为null、空字符串
* @param list 源list
* @param pageSize 每页数量
* @param pageNum 页数
* @return
*/
@SuppressWarnings("rawtypes")
public static List subList(List list,int pageSize,int pageNum)throws NumberFormatException{
  List returnList = null;
  if(pageSize == 0 || pageNum == 0 || list.size() < 1){
    returnList = list;
  }else{
    int startSize = (pageNum - 1) * pageSize;
    int endSize = pageNum * pageSize;
    if(list.size() < endSize){
      endSize = list.size();
    }
    returnList = list.subList(startSize, endSize);
  }
  return returnList;
}

上一篇:自学RF定位下拉框改变页码pagesize


下一篇:mysql查询优化总结