原先使用的是全部都是hibernate进行分页。完全可以实现然后后来增加功能,由于实现的原因,使用的jdbc进行实现的。使用jdbc添加了数据之后再用hibernate显示是页数出现错误。和实际条数不服。只会显示没用纯jdbc的那个数改怎么办
解决方案 »
- 懂hibernate判断的进!!
- 关于$(document).ready的一个问题。
- HttpURLConnection Authenticator 密码错误 紧急求助
- 做网站是修改别人的摸版还是自己一行一行代码敲进去啊
- 请问一个关于window.open的问题
- 很菜的 jsp传值问题 分少 有愿意帮忙的吗 在线等
- java.lang.NumberFormatException
- 用户与浏览器交互会触发的所有事件??
- 谁又用applet和servlet做的时时显示数据库变化的走势图的例子。最好能够实现他们的交互。必有重谢
- jdbc连接sq server2000问题
- [求助]在请求(request)范围内的JavaBean
- struts2 freemarker 难不难学?
并且这不是代码的问题这样吧。有一个查询界面是所有的客户资料。。 用hibernate实现了分页然后有个导入,用的纯jdbc实现的。导入成功之后。这个页面不管怎么刷新。分页的地方,记录数页数都是导入之前的数。
这是我用的。jdbc和hibernate都适用package com.psit.struts.common;public class Page {
/**
* 当前页
*/
private int currentPageNo;
/**
*下一页
*/
private int nextPageNo;
/**
* 上一页
*/
private int prePageNo;
/**
* 第一页
*/
private int firstPageNo; /**
* 最后一页
*/
private int lastPageNo;
/**
* 页大小
*/
private int pageSize ;
/**
* 多少行
*/
private int rowsCount;
/**
* 多少页
*/
private int pageCount;
/**
* 初始化
* @param rowsCount
* @param pageSize
*/
public Page(int rowsCount,int pageSize)
{
this.rowsCount = rowsCount;
this.pageSize = pageSize;
} public int getCurrentPageNo() {
if(this.currentPageNo > this.getLastPageNo())
{
this.setCurrentPageNo(this.getLastPageNo());
}
if(this.currentPageNo < this.getFirstPageNo())
{
this.setCurrentPageNo(this.getFirstPageNo());
}
return currentPageNo;
} public void setCurrentPageNo(int currentPageNo) {
this.currentPageNo = currentPageNo;
} /**
* 获得下一页码
* @return
*/
public int getNextPageNo() {
this.nextPageNo = this.currentPageNo + 1;
if(this.nextPageNo>this.getPageCount())
{
this.nextPageNo = this.getPageCount();
}
return nextPageNo;
} /**
* 获得总页数
* @return
*/
public int getPageCount() {
if(this.rowsCount % this.pageSize == 0)
{
this.pageCount = this.rowsCount / this.pageSize;
}
else
{
this.pageCount = (this.rowsCount / this.pageSize) + 1;
}
return pageCount;
} /**
* 获得前一页码
* @return
*/
public int getPrePageNo() {
this.prePageNo = this.currentPageNo - 1;
if(this.prePageNo <=0 )
{
this.prePageNo = 1;
}
return prePageNo;
} /**
* 获得第一页
* @return
*/
public int getFirstPageNo() {
this.firstPageNo = 1;
return firstPageNo;
} /**
* 获得最后一页
* @return
*/
public int getLastPageNo() {
this.lastPageNo = this.getPageCount();
return lastPageNo;
} public int getPageSize() {
return pageSize;
} public int getRowsCount() {
return rowsCount;
} public void setPageCount(int pageCount) {
this.pageCount = pageCount;
}}