仅供参考:
private void locationPage(){
this.request = this.getRequest();
strStartRecord = request.getParameter("startRecord");
if(strStartRecord==null||strStartRecord.length()<=0){
strStartRecord = "0";
} strDisplayLength = request.getParameter("displayLength");
if(strDisplayLength==null||strDisplayLength.length()<=0){
strDisplayLength="10";
} if(!(strDisplayLength==null||strDisplayLength.length()<=0)){
lDisplayLength=Integer.parseInt(strDisplayLength);
}
else lDisplayLength =10; page_location = request.getParameter("page_location");
if(page_location==null||page_location.length()<=0){
page_location = "";
}
try{
if (Integer.parseInt(page_location)<=0)
page_location = "";
}
catch(NumberFormatException e){
page_location = "";
} if(!(page_location.length()==0)){
String rsCount = request.getParameter("count");
long lrsCount = Integer.parseInt(rsCount);
long temp = Integer.parseInt(page_location)*lDisplayLength;
if (lrsCount >= temp){
lStartRecord=(Integer.parseInt(page_location)-1)*lDisplayLength;
strStartRecord = String.valueOf(lStartRecord);
}
else {
if (lrsCount%lDisplayLength ==0)
lStartRecord = lrsCount/lDisplayLength*lDisplayLength - lDisplayLength;
else lStartRecord = lrsCount/lDisplayLength*lDisplayLength;
strStartRecord = String.valueOf(lStartRecord);
}
}
else if(!(strStartRecord==null||strStartRecord.length()<=0)){
lStartRecord=Integer.parseInt(strStartRecord);
}
} public int getCount(){
return this.count;
} public String getStrStartRecord(){
return this.strStartRecord;
} public String getStrDisplayLength(){
return this.strDisplayLength;
} public long getLStartRecord(){
return this.lStartRecord;
} public long getLDisplayLength(){
return this.lDisplayLength;
}locationPage()在做数据库查询前调用,在做rs结果集循环时:
while (rs.next()){
i++;
count++;
if((i>lStartRecord)&&(i<=(lStartRecord+lDisplayLength))){
。
。
。
}
}后面的方法在jsp里调用就可以做分页处理了!
private void locationPage(){
this.request = this.getRequest();
strStartRecord = request.getParameter("startRecord");
if(strStartRecord==null||strStartRecord.length()<=0){
strStartRecord = "0";
} strDisplayLength = request.getParameter("displayLength");
if(strDisplayLength==null||strDisplayLength.length()<=0){
strDisplayLength="10";
} if(!(strDisplayLength==null||strDisplayLength.length()<=0)){
lDisplayLength=Integer.parseInt(strDisplayLength);
}
else lDisplayLength =10; page_location = request.getParameter("page_location");
if(page_location==null||page_location.length()<=0){
page_location = "";
}
try{
if (Integer.parseInt(page_location)<=0)
page_location = "";
}
catch(NumberFormatException e){
page_location = "";
} if(!(page_location.length()==0)){
String rsCount = request.getParameter("count");
long lrsCount = Integer.parseInt(rsCount);
long temp = Integer.parseInt(page_location)*lDisplayLength;
if (lrsCount >= temp){
lStartRecord=(Integer.parseInt(page_location)-1)*lDisplayLength;
strStartRecord = String.valueOf(lStartRecord);
}
else {
if (lrsCount%lDisplayLength ==0)
lStartRecord = lrsCount/lDisplayLength*lDisplayLength - lDisplayLength;
else lStartRecord = lrsCount/lDisplayLength*lDisplayLength;
strStartRecord = String.valueOf(lStartRecord);
}
}
else if(!(strStartRecord==null||strStartRecord.length()<=0)){
lStartRecord=Integer.parseInt(strStartRecord);
}
} public int getCount(){
return this.count;
} public String getStrStartRecord(){
return this.strStartRecord;
} public String getStrDisplayLength(){
return this.strDisplayLength;
} public long getLStartRecord(){
return this.lStartRecord;
} public long getLDisplayLength(){
return this.lDisplayLength;
}locationPage()在做数据库查询前调用,在做rs结果集循环时:
while (rs.next()){
i++;
count++;
if((i>lStartRecord)&&(i<=(lStartRecord+lDisplayLength))){
。
。
。
}
}后面的方法在jsp里调用就可以做分页处理了!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货