java返回list 写分页

int row = actParamVo.getRow();
int page = actParamVo.getPage();
if (page * row <= resultList.size()) {
resultList = resultList.subList((page - 1) * row, row);
} else if ((page - 1) * row < resultList.size() && page * row > resultList.size()) {
resultList = resultList.subList((page - 1) * row, resultList.size() - ((page - 1) * row));
} else if ((page - 1) * row > resultList.size() && page * row > resultList.size()) {
resultList.clear();
}
return new PageResult(resultList.size(), resultList);

public class PageResult implements Serializable{
private long total; // 总记录数
private List rows; // 返回每页的数据的集合

public PageResult(long total, List rows) {
	super();
	this.total = total;
	this.rows = rows;
}
public long getTotal() {
	return total;
}
public void setTotal(long total) {
	this.total = total;
}
public List getRows() {
	return rows;
}
public void setRows(List rows) {
	this.rows = rows;
}

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