用hibernate+spring做的分页,点过几次后,就提示一个和页面不相关的action不能打开.
分页代码:
public List findPage(String hql,int first,int max){
List result = new ArrayList();
Session sess = null;
try{
log.error("=====find page in try=======");
sess = (Session) getSession();
// super.getSession();
Query query = sess.createQuery(hql);
query.setFirstResult(first);
query.setMaxResults(max);
// System.out.println("===========hql: " + hql);
long date1 = new Date().getTime();
result = query.list();
long date2 = new Date().getTime();
log.error("========get page spend " + (date2-date1) + " seconds");
}catch(RuntimeException re){
log.error("========exception========");
re.printStackTrace();
} finally {
if (sess != null) {
sess.close();
log.error("==========session closed=========");
}
}
最多的情况是从最后一页跳到第一页的时候出错.错误如图: