`

java中对查询出的结果集List进行分页显示

    博客分类:
  • java
阅读更多
public class ListSub{
    /**
     * 当前页面
     */
    private int page = 1;

    /**
     * 显示多少行
     */
    private int rows = 15;

    /**
     * 总记录条数
     */
    private int total;

    /**
     * @return the page
     */
    public int getPage() {
        return page;
    }

    /**
     * @param page the page to set
     */
    public void setPage(int page) {
        this.page = page;
    }

    /**
     * @return the rows
     */
    public int getRows() {
        return rows;
    }

    /**
     * @param rows the rows to set
     */
    public void setRows(int rows) {
        this.rows = rows;
    }

    /**
     * @return the total
     */
    public int getTotal() {
        return total;
    }

    /**
     * @param total the total to set
     */
    public void setTotal(int total) {
        this.total = total;
    }

    /**
     * 对list集合进行分页处理
     * 
     * @return
     */
    private List<E> ListSplit(List<E> list) {
        List<E> newList=null;
        total=list.size();
        newList=list.subList(rows*(page-1), ((rows*page)>total?total:(rows*page)));
        return newList;
    }

}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics