我正在做一个学生管理系统。
在里面要做一个分页界面,要从数据库里动态的提取数据(比如每次只能提取10条,在页面中显示10条,下一个页面在显示数据库后面的10条数据)。
由于本人刚学习java,还不能实现此功能希望各位高手帮我实现一下。本人在此谢过!!!!!!!!(具体的代码)
在里面要做一个分页界面,要从数据库里动态的提取数据(比如每次只能提取10条,在页面中显示10条,下一个页面在显示数据库后面的10条数据)。
由于本人刚学习java,还不能实现此功能希望各位高手帮我实现一下。本人在此谢过!!!!!!!!(具体的代码)
<table id="tab" width="80%" height="20" border="0" cellpadding="3" cellspacing="1" bgcolor="86B9D6" class="zhengwen" >
<tr align="center" bgcolor="#D7E9FF" > <!--输出表头-->
<th>序号</th>
<th>名单名</th>
<th>发布日期</th>
<th>属性数</th>
<th>记录数</th>
<th>模型名</th>
</tr>
<!-- 输出内容 -->
<logic:present name="dataList">
<logic:iterate id="comp" name="dataList" type="cn.com.xinli.entity.Comparison" >
<tr align="center">
<td><bean:write name="comp" property="id"/></td>
<td><a href="select.do?tableName=<bean:write name="comp" property="name"/>">
<bean:write name="comp" property="realname"/></A></td>
<td><bean:write format="yyyy-MM-dd" name="comp" property="releasedate"/></td>
<td><%=comp.getAttributes()%></td>
<td><%=comp.getInstances()%></td>
<td><bean:write name="comp" property="modelname"/></td>
</tr>
</logic:iterate>
</logic:present>
</table>
<%
webappLogger.info("currentPage:"+currentPage);
if(currentPage==1) //如果是第一页
last ="hidden";
if(currentPage==lp) ////如果是最后页
next ="hidden";
%>
<table>
<tr>
<td align="left" colspan="5" color=red><font color=red>
<%if((String)request.getAttribute("dberror")!=null) out.print((String)request.getAttribute("dberror"));%>
</font>
</td>
<td height="20" colspan="2" >
<%
String se1 = "";
String se2 = "";
String se3 = "";
String pc="10";
if(pageForm!=null){
pc = pageForm.getPageCount();
}
if(pc==null){
pc="10";
}
if(pc.equals("10")) se1 = "selected";
if(pc.equals("20")) se2 = "selected";
if(pc.equals("30")) se3 = "selected";
%>
每页记录数目:
<select name="pageCount" size=1 onChange="firstpage()">
<option value= 10 <%=se1%>>10</option>
<option value= 20 <%=se2%>>20</option>
<option value= 30 <%=se3%>>30</option>
</select>
</td>
<td align="left">
<input name="button0" type="button" value="首 页" onclick="firstpage()"/>
<input name="button1" type="<%=last%>" value="上一页" onclick="lastpage()"/>
<input name="button2" type="<%=next%>" value="下一页" onclick="nextpage()"/>
<input name="button3" type="button" value="末 页" onclick="finalpage()"/>
</td>
<td align="center">
<input type="hidden" name="pageNo" value="<%=currentPage%>" />第<%=currentPage%>页
</td>
<td align="right">
<input type="hidden" name="totalPage" value="<%=lp%>" />
共<%=lp%>页
</td>
<td align="center">
<input type="hidden" name="tableName" value="<%=tableName%>" />
</td>
<td>
<input type="hidden" name="pageName" value="more" />
</td>
<td>
转到<select name="randomPage" size=1 onchange="randompage()" />
<option value="">...</option>
<%
for(int k=1;k<=lp;k++)
{
%>
<option value=<%=k-1%> ><%=k%></option>
<%
}
%>
</select>页
</td>
</tr>
</table>
</form>这是页面显示(默认显示每页10条),具体操作数据库的语句(下一页按钮):
select * from users where rownum<=20 minus (select * from users where rownum<=10)
主要是这句,希望对你有帮助.