请教高手如何用taglib(自定义标签)分页显示
package bank.based.network.taglib;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import
javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTag;
import javax.servlet.jsp.tagext.Tag;
import bank.based.network.bean.JDBCCon;
public class TranLog implements BodyTag
{
public void getPage()
{
Connection con = null;
ResultSet rs = null;
int pagesize = 10;//每页显示十条记录
try
{
Statement st = con.createStatement();
con = JDBCCon.getConnection();
String sql = "select count(*) from transfermoney_log ";
rs = st.executeQuery(sql);
int pagesum = rs.getRow();//查询出数据库中的总记录
int page = pagesum/pagesize;//的到多少页
}
catch(Exception e)
{
e.printStackTrace();
}
}
public int doEndTag() throws
JspException {
// TODO Auto-generated method stub
return 0;
}
public int doStartTag() throws JspException
{
// TODO Auto-generated method stub
return 0;
}
public void doInitBody() throws JspException
{
// TODO Auto-generated method stub
}
public void setBodyContent(BodyContent arg0)
{
// TODO Auto-generated method stub
}
public int doAfterBody() throws JspException
{
// TODO Auto-generated method stub
return 0;
}
public Tag getParent()
{
// TODO Auto-generated method stub
return null;
}
public void release()
{
// TODO Auto-generated method stub
}
public void setPageContext(PageContext arg0)
{
// TODO Auto-generated method stub
}
public void setParent(Tag arg0)
{
// TODO Auto-generated method stub
}
}
我的问题就是:
查询出数据库中的几百条数据
每十条为一页
int page = pagesum/pagesize得到的不一定整数页数
怎么保持显示的一致性
不在JSP里写JAVA代码
都写在taglib(自定义标签)里
请教高手这个程序应该怎么改
------解决方案--------------------直接使用JSTL
------解决方案--------------------我这边是用structs+taglib做的翻页,其中数据显示用structs标签,而当前页数的显示,及上一页,下一页的控制都用taglib做的自定义标签.jsp代码如下:
<logic:present name= "List1 " scope= "request ">