WEB开发网
开发学院WEB开发Jsp 一种高效的javabea分页For SqlServer 阅读

一种高效的javabea分页For SqlServer

 2008-01-05 09:38:02 来源:WEB开发网   
核心提示:一种高效的javabea分页For SqlServer <%@ page contentType="text/Html;charset=GB2312"%> <%@ page import="ite.com.*,java.util.*"%

  一种高效的javabea分页For SqlServer

<%@ page contentType="text/Html;charset=GB2312"%>
<%@ page import="ite.com.*,java.util.*"%>
<title>分页显示ForSQLServer使用Select分页</title>
<style type="text/CSS">
<!--
table { background-color: #000000;}
td {background-color: #FFFFFF;}
-->
</style>
<%
java.util.List rstlist=new java.util.ArrayList();
//数据库连接池初始化
DBManager dbm=new DBManager();
dbm.setDatasource("java:comp/env/jdbc/lerp");
int pagesize=10;
int pageno=0;
if (request.getParameter("pageno")==null){
pageno=1;
}else{
pageno=Integer.parseInt(request.getParameter("pageno"));
if(pageno<=0){
pageno=1;
}
}
//使用Select实现分页显示
//String sql=select top 每页显示记录数 * from tablename where id not in(select top 每页显示记录数*(显示当前页-1) id from tablename)
String sql="select top "+pagesize+" * from iokecontent where id not in(select top "+pagesize*(pageno-1)+" id from iokecontent where iokesort=54 order by id desc) and iokesort=54 order by id desc";
rstlist=dbm.queryByPage_SQL_Quick(sql);

out.PRintln("<table border=0 cellpadding=1 cellspacing=1 width=200>");
out.println("<tr><td>字段一</td><td>字段二</td></tr>");
for(int i=0;i<rstlist.size();i++){
out.println("<tr><td>"+((java.util.ArrayList)rstlist.get(i)).get(0)+"</td><td>"+((java.util.ArrayList)rstlist.get(i)).
get(2)+"</td></tr>");
}
out.println("</table>");

out.println("<a href=selectpage.jsp?pageno="+(pageno-1)+">上一页</a>");
out.println("<a href=selectpage.jsp?pageno="+(pageno+1)+">下一页</a>");

%>

Tags:高效 javabea For

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接