javabean是什么意思?
分页具体是什么意思?
网页的分页?public List queryForPage(int currentPage,int pageSize)
{
..................//sessionFactory
..................//Transaction
Query query=session.createQuery("User.class");
int firstRecord=(currentPage-1)*pageSize;//为什么要-1?这句表示什么意思?
query.setFirstResult(firstRecord);// 这是从第几页开始显示记录?为什么是firstRecord?
query.seyMaxResults(pageSize); .....................//commit,close;}
分页具体是什么意思?
网页的分页?public List queryForPage(int currentPage,int pageSize)
{
..................//sessionFactory
..................//Transaction
Query query=session.createQuery("User.class");
int firstRecord=(currentPage-1)*pageSize;//为什么要-1?这句表示什么意思?
query.setFirstResult(firstRecord);// 这是从第几页开始显示记录?为什么是firstRecord?
query.seyMaxResults(pageSize); .....................//commit,close;}
分页就是:你正常网页看到也有的每页10行数据什么的,如有N条记录就会有
n/10=0?(n/10):(n/10+1)这么多页
currentPage和pageSize各代表什么意思啊?
public class CustomerEntity extends AbsValueBean {
private String address;
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
分页就类似于您在网站里看到的“上页、下页、首页、末页”。
可以加我QQ:40200142,咱们可以相互交流。
currentPage表示当前页
pageSize 表示每页要显示多少个?Query query=session.createQuery("User.class");
int firstRecord=(currentPage-1)*pageSize;//为什么要-1?这句表示什么意思?
你这个属于是hibernate的分页
那我打个比方给你 比如现在是要显示第5页,每页显示10条数据,那firstRecord=(currentPage-1)*pageSize的值就是40
query.setFirstResult(firstRecord);// 这是从第几页开始显示记录?为什么是firstRecord?
你查询的就是从第40个之后开始的
query.seyMaxResults(pageSize);
你每页显示10条
那么int firstRecord=(currentPage-1)*pageSize;
就表示当前页的第一条记录,如第5页,即currentPage=5,那第5页的第一条记录就是firstRecord=(5-1)*10=40
当第一页第一条记录 firstRecord=(1-1)*5=0 (注意:5是记录数)
第二页第一条记录 firstRecord=(2-1)*5 =5
依次类推int firstRecord=(currentPage-1)*pageSize;//为什么要-1
一般编号都是从0123这样的顺序,而页码 没有第0页
楼主这些代码不是你写的吗? int firstRecord=(currentPage-1)*pageSize;//为什么要-1?这句表示什么意思?
这句话是在sql语句中要排除的条件,currentPage应该是表示的当前要查询的页面页码,-1然后再*pagesSize(每页要显示的条数)就是要排除当前页前面已经显示过的信息 query.setFirstResult(firstRecord);// 这是从第几页开始显示记录?为什么是firstRecord?
这句话没看懂什么意思!