我现在用的是,struts 和 spring 做的项目,我想问,如果我做分页的话,用什么分页会更好些。如何做。

解决方案 »

  1.   

    用struts写的一个泛型通用分页类,可以考虑下:
    public class DividePage {
    @SuppressWarnings("unchecked")
    public static int totalRecord;
    public static int pageCount;
    @SuppressWarnings("unchecked")
    public static <T>T getList(Integer pageSize,Integer currentPage,List<T> list){
    int totalrecord;
    int pagecount;
    totalrecord = list.size();
    pagecount=(totalrecord+pageSize-1)/pageSize;
    List<T> list1 = new ArrayList<T>();
    if(currentPage==null){
    currentPage=1;
    }
    if(currentPage<pagecount){
    for(int i=(currentPage-1)*pageSize;i<currentPage*pageSize;i++){
    list1.add(list.get(i));
    }
    }
    else {
    for(int i=(currentPage-1)*pageSize;i<totalrecord;i++){
    list1.add(list.get(i));
    }
    }
    totalRecord = totalrecord;
    pageCount = pagecount;
    return (T)list1;
    }
    }
      

  2.   

    hibernate的分页简单,可以去看看。