mysql中分页可以用limit来实现
例如:
String sql="select * from shop where EmployeeId ='"+id+"' Limit "+offset+","+count+" ";
count表示一页显示多少条;
offset表示偏移量,与count配合使用,用于多次请求,offset = (请求次数 - 1) * count
在实现分页过后用count(*)来计算查询到的所有数据量,同上例如:
String sql01="select count(*)from shop where EmployeeId ='"+id+"' ";
后面可以用number来接受这个值(int类型),
if (rs01 != null) {
try {
if(rs01.next()) {
number=rs01.getInt(1);
}
}catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
最后想要知道当前页所显示的条目数,定义为resnumber
int resnumber = items.size();
(items同上一篇文档里的作用,是一个接收查询结果的list)
做完了 觉得蛮简单,也谢谢潘玉同学的指导!