zzyzy1195 2017-05-25 13:47 采纳率: 0%
浏览 1092
已结题

hql分页上一页下一页的问题

public List query(int pageIndex) {
List list=null;
Configuration cof=null;
SessionFactory sf=null;
Session s=null;
try {
cof=new Configuration().configure();
sf=cof.buildSessionFactory();
s=sf.openSession();
String hql="from Teacher";
Query query=s.createQuery(hql);
int pageSize=2;
query.setMaxResults(pageSize);
query.setFirstResult((pageIndex-1)*pageSize);
list=query.list();

} catch (Exception e) {
    e.printStackTrace();
}finally{
    s.close();
}
return list;
}

这是daoimpl中的分页语句,怎么在jsp页面中显示上一页下一页,
  • 写回答

3条回答 默认 最新

  • 站在风口哈气 2017-05-25 14:30
    关注

    通过修改你代码中的那个pageIndex,第一页pageIndex就是1,第二页pageIndex就是2。。。。。。也就是下一页就加1,上一页就减1

    评论

报告相同问题?