对list进行分页处理
代码示例:
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;}}
核心代码: list.subList(rows(page-1), ((rowspage)>total?total:(rows*page)));
