....i=0;
while(i<(intPageSize*(intpage-1)){
i++;
sqlRst.next();
}
i=0;
boolean sign=true;
while(i<intPageSize &&sign){
%>
<tr>
<td><%=sqlRst.getString("username")%></td>
<td><%=sqlRst.getString("phonecode")%></td>
</tr>
<%
sign=sqlRst.next();
i++;
}
....
while(i<(intPageSize*(intpage-1)){
i++;
sqlRst.next();
}
i=0;
boolean sign=true;
while(i<intPageSize &&sign){
%>
<tr>
<td><%=sqlRst.getString("username")%></td>
<td><%=sqlRst.getString("phonecode")%></td>
</tr>
<%
sign=sqlRst.next();
i++;
}
....
解决方案 »
- 多个https webservice调用,设置keystore冲突的问题
- 关于ext js显示后台得到的数据
- 更新数据问题??
- 同时有两个问题求教,大家帮帮我
- hibernate oracle不自动产生sequence
- 请问在jsp中如何将数字转换成特定金额的格式?
- 一个关于javabean的问题
- 如何把该url www.mysite.com/myaction?year=2007&month=09改写成www.mysite.com/myaction/2007/09,并且能够映射到myaction
- 反编译问题
- 关于jsp用户验证的问题
- 菜鸟问题,javax.servlet.ServletException: No data found?怎么回事?
- 大家看看我做的这个链接数据库的BEAN,还应做什么调整能达到最优
import java.util.*;/**
* Title:分页
* Description:
* Copyright: Copyright (c) 2004
* Company:
* author:颜喜班
* @version 1.0
*/
public class SplitPager
{
/*
* _sql_str:传入的sql语句
* _total_records: 总记录数目
* _pageSize: 每页显示的记录数目
* _page: 所分的逻辑页数
*/
private Connection con=null;
private Statement stmt=null;
private ResultSet rs=null;
private ResultSetMetaData rsmd=null;
private String _sql_str;
private int _total_records;
private int _pages;
private int _pagesize;
public void setConnection(Connection con)
{
this.con=con;
if (this.con == null)
System.out.println("Failure to get a connection!");
else
System.out.println("Success to get a connection!");
}
public void initialize(String sqlStr,int pageSize)
{
this._sql_str=sqlStr;
this._pagesize=pageSize;
try{
stmt=this.con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery(this._sql_str);
rsmd=rs.getMetaData();
if (rs!=null)
{
rs.last();
this._total_records = rs.getRow();
rs.first();
this._pages = (this._total_records - 1) / this._pagesize + 1;
}
}
catch(SQLException e){System.out.println(e.toString()); }
}
public Vector getPage(int ipage){
Vector vData=new Vector();
int n=ipage;
int m=0;
m=(n-1)*this._pagesize+1;
try{
if (rs!=null)
{
rs.absolute(m);
for(int i=0;i<this._pagesize;i++){
String[] sData=new String[rsmd.getColumnCount()];
for(int j=0;j<rsmd.getColumnCount();j++)
{
sData[j]=rs.getString(j+1);
}
if (sData==null)
{
break;
}
vData.addElement(sData);
rs.next();
}
}
rs.close();
stmt.close();
}
catch(SQLException e){System.out.println(e.toString()); }
return vData;
}
public int getPages()
{
return this._pages;
}
public int getTotalRecords()
{
return this._total_records;
}}
请问在jsp中是怎样调用这个bean的,能否贴出来。
* 按照页码范围分页的方法
* @param jspName 要进行分页的jsp文件名
* @param pageNo 当前页
* @param totalPage 总页数
* @param pageSize 放置的页数
*/
public static String getPageRange(String jspName,int pageNo,int totalPage,int pageSize)
{
int startPageNo=pageNo/pageSize*pageSize;
int endPageNo=startPageNo+pageSize;
StringBuffer buf=new StringBuffer();
buf.append("<p align=center>");
if(startPageNo>0)
buf.append("<a href=\""+jspName+"?pageNo="+(startPageNo-pageSize+1)+"\">[<<<]</a>");
for(int i=1;i<=pageSize;++i)
buf.append("<a href=\""+jspName+"?pageNo="+(startPageNo+i)+"\">["+(startPageNo+i)+"]</a> ");
if(endPageNo!=totalPage)
buf.append("<a href=\""+jspName+"?pageNo="+(endPageNo)+"\">[>>>]</a>");
buf.append("</p>");
buf.append("<p align=center>第"+pageNo+"页 共"+totalPage+"页</p>");
return buf.toString();
}