JSP中分页显示的问题

来源:百度知道 编辑:UC知道 时间:2024/05/31 14:46:48
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:xiaole");
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery("select count(*) from NA" );

rs.next();
RecordCount = rs.getInt(1);

rs = statement.executeQuery("select top 3 * from NA where id not in(select top "+((PageNo-1)*3)+" id from NA ) ");

//获取总页数
MaxPage = RecordCount % PageSize;
if(RecordCount % PageSize == 0){
MaxPage = RecordCount / PageSize;
}else{
MaxPage = RecordCount/PageSize+1;
}
%>
<table width="100%" border="0" class="InternalHeader">
<tr>
<td width="24%"><font size=4>欢迎购物</font></td>
<td width="76%">
<font size=4><%="总共"+RecordCoun

汗...你的代码真乱啊!怎么没用mvc模式分层呢?这样看代码好累哦!把你的数据库代码和jsp视图代码分开,尽量完成模型和视图的分离啊!你完成了分页的话,分列就在循环里面加个表单,<TD>
这样就可以了,你既然分页都实现了,那应该分列也很容易了!不过你的代码看的实在累人呀!呵呵...

建议用数据库存储过程分页,或者模拟存储过程,效率,速度都高