1.创建SQL
2.创建分页实体
public class DataGridResult {
private long total;
private List<?> 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;
}
}
3.计算分页
public DataGridResult queryStudentInfo(@RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "rows", defaultValue = "10") int pageSize) {
int begin = (page - 1) * pageSize + 1;
int end = page * pageSize;
DataGridResult dataGridResult = studentService.queryStudentInfo(begin,end);
return dataGridResult;
}
DataGridResult dataGridResult = new DataGridResult();
dataGridResult.setTotal(count);//分页总数 int
dataGridResult.setRows(countVo);//需要分页的数据List