jsp 如何将查询结果实现分页,最好简单易懂…
2个回答
2015-12-15 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
jsp中分页最快捷的办法是用分页组件:
分页组件代码使用taglib实现的:
<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ attribute name="curIndex" type="java.lang.Long" required="true"%>
<%@ attribute name="pageSize" type="java.lang.Long" required="true"%>
<%@ attribute name="pagerRange" type="java.lang.Long" required="true"%>
<%@ attribute name="totalPage" type="java.lang.Long" required="true"%>
<%@ attribute name="formId" type="java.lang.String" required="true"%>
<%
long begin = Math.max(1, curIndex - pagerRange/2);
long end = Math.min(begin + (pagerRange-1),totalPage);
request.setAttribute("p_begin", begin);
request.setAttribute("p_end", end);
%>
<table class="pager">
<tr>
<% if (curIndex!=1){%>
<td><a href="javascript:gotoPage(1)">首页</a></td>
<td><a href="javascript:gotoPage(<%=curIndex-1%>)">上一页</a></td>
<%}else{%>
<td class="disabled"><a href="#">首页</a></td>
<td class="disabled"><a href="#">上一页</a></td>
<%}%>
<c:forEach var="i" begin="${p_begin}" end="${p_end}">
<c:choose>
<c:when test="${i == curIndex}">
<td class="active"><a href="#">${i}</a></td>
</c:when>
<c:otherwise>
<td><a href="javascript:gotoPage(${i})">${i}</a></td>
</c:otherwise>
</c:choose>
</c:forEach>
<% if (curIndex!=totalPage){%>
<td><a href="#">下一页</a></td>
<td><a href="#">末页</a></td>
<%}else{%>
<td class="disabled"><a href="javascript:gotoPage(<%=curIndex+1%>)">下一页</a></td>
<td class="disabled"><a href="javascript:gotoPage(<%=totalPage%>)">末页</a></td>
<%}%>
<td><a>共${totalPage}页</a></td>
<td class="input_li">跳转到:<input type="text" id="p_pageIndex" size="2" value="<c:out value="${pageIndex}"/>"/>页 <input type="button" id="gotoBtn" onclick="gotoPageByBtn()" value="GO"/></td>
<td class="input_li"> 每页:
<select id="p_pageSizeSelect" onchange="gotoPage(<%=curIndex%>)">
<option value="10" <c:if test="${pageSize==10}">selected</c:if>>10条</option>
<option value="20" <c:if test="${pageSize==20}">selected</c:if>>20条</option>
<option value="50" <c:if test="${pageSize==50}">selected</c:if>>50条</option>
</select>
</td>
</tr>
</table>
jsp中使用方法:
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt"%>
<%@ taglib tagdir="/WEB-INF/tags" prefix="tags"%>
<head>
<style><!--分页样式-->
.pager { font: 12px Arial, Helvetica, sans-serif;}
.pager a {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;margin-right:2px;line-height:30px;vertical-align:middle;}
.pager .active a{color:red;border:none;}
.pager a:visited {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;}
.pager a:hover {color: #fff; background: #ffa501;border-color:#ffa501;text-decoration: none;}
.pager .input_li{padding: 1px 6px;}
</style>
<script><!--分页跳转脚本-->
function gotoPage(pageIndex){
var queryForm = document.getElementById("queryForm");
var action = queryForm.action;
var pageSize = document.getElementById("p_pageSizeSelect").value;
action += "?pageIndex=" + pageIndex + "&pageSize=" + pageSize;
//alert(action);
queryForm.action = action;
queryForm.submit();
}
function gotoPageByBtn(){
var pageIndex = document.getElementById("p_pageIndex").value;
var pageIndexInt = parseInt(pageIndex);
var totalPage = ${totalPage};
if(pageIndexInt>0 && pageIndexInt<totalPage){
gotoPage(pageIndex);
}
else{
alert("输入页数超出范围!");
}
}
</script>
</head>
<body>
<form id="queryForm" action="${basePath}/log/list" method="post">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="userName" value="<c:out value="${userName}"/>"/> </td>
<td><input type="submit" text="查询"/></td>
</tr>
</table>
</form>
<tags:pager pagerRange="10" pageSize="${pageSize}" totalPage="${totalPage}" curIndex="${pageIndex}" formId="queryForm"></tags:pager>
<table class="border">
<thead>
<tr>
<th width="100">用户名称</th>
<th width="500">操作内容</th>
<th width="200">操作时间</th>
</tr>
</thead>
<tbody>
<c:forEach items="${logList}" var="log">
<tr>
<td>${log.userName}</td>
<td>${log.result}</td>
<td>
<fmt:formatDate value="${log.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<tags:pager pagerRange="10" pageSize="${pageSize}" totalPage="${totalPage}" curIndex="${pageIndex}" formId="queryForm"></tags:pager>
</body>
分页组件代码使用taglib实现的:
<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ attribute name="curIndex" type="java.lang.Long" required="true"%>
<%@ attribute name="pageSize" type="java.lang.Long" required="true"%>
<%@ attribute name="pagerRange" type="java.lang.Long" required="true"%>
<%@ attribute name="totalPage" type="java.lang.Long" required="true"%>
<%@ attribute name="formId" type="java.lang.String" required="true"%>
<%
long begin = Math.max(1, curIndex - pagerRange/2);
long end = Math.min(begin + (pagerRange-1),totalPage);
request.setAttribute("p_begin", begin);
request.setAttribute("p_end", end);
%>
<table class="pager">
<tr>
<% if (curIndex!=1){%>
<td><a href="javascript:gotoPage(1)">首页</a></td>
<td><a href="javascript:gotoPage(<%=curIndex-1%>)">上一页</a></td>
<%}else{%>
<td class="disabled"><a href="#">首页</a></td>
<td class="disabled"><a href="#">上一页</a></td>
<%}%>
<c:forEach var="i" begin="${p_begin}" end="${p_end}">
<c:choose>
<c:when test="${i == curIndex}">
<td class="active"><a href="#">${i}</a></td>
</c:when>
<c:otherwise>
<td><a href="javascript:gotoPage(${i})">${i}</a></td>
</c:otherwise>
</c:choose>
</c:forEach>
<% if (curIndex!=totalPage){%>
<td><a href="#">下一页</a></td>
<td><a href="#">末页</a></td>
<%}else{%>
<td class="disabled"><a href="javascript:gotoPage(<%=curIndex+1%>)">下一页</a></td>
<td class="disabled"><a href="javascript:gotoPage(<%=totalPage%>)">末页</a></td>
<%}%>
<td><a>共${totalPage}页</a></td>
<td class="input_li">跳转到:<input type="text" id="p_pageIndex" size="2" value="<c:out value="${pageIndex}"/>"/>页 <input type="button" id="gotoBtn" onclick="gotoPageByBtn()" value="GO"/></td>
<td class="input_li"> 每页:
<select id="p_pageSizeSelect" onchange="gotoPage(<%=curIndex%>)">
<option value="10" <c:if test="${pageSize==10}">selected</c:if>>10条</option>
<option value="20" <c:if test="${pageSize==20}">selected</c:if>>20条</option>
<option value="50" <c:if test="${pageSize==50}">selected</c:if>>50条</option>
</select>
</td>
</tr>
</table>
jsp中使用方法:
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt"%>
<%@ taglib tagdir="/WEB-INF/tags" prefix="tags"%>
<head>
<style><!--分页样式-->
.pager { font: 12px Arial, Helvetica, sans-serif;}
.pager a {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;margin-right:2px;line-height:30px;vertical-align:middle;}
.pager .active a{color:red;border:none;}
.pager a:visited {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;}
.pager a:hover {color: #fff; background: #ffa501;border-color:#ffa501;text-decoration: none;}
.pager .input_li{padding: 1px 6px;}
</style>
<script><!--分页跳转脚本-->
function gotoPage(pageIndex){
var queryForm = document.getElementById("queryForm");
var action = queryForm.action;
var pageSize = document.getElementById("p_pageSizeSelect").value;
action += "?pageIndex=" + pageIndex + "&pageSize=" + pageSize;
//alert(action);
queryForm.action = action;
queryForm.submit();
}
function gotoPageByBtn(){
var pageIndex = document.getElementById("p_pageIndex").value;
var pageIndexInt = parseInt(pageIndex);
var totalPage = ${totalPage};
if(pageIndexInt>0 && pageIndexInt<totalPage){
gotoPage(pageIndex);
}
else{
alert("输入页数超出范围!");
}
}
</script>
</head>
<body>
<form id="queryForm" action="${basePath}/log/list" method="post">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="userName" value="<c:out value="${userName}"/>"/> </td>
<td><input type="submit" text="查询"/></td>
</tr>
</table>
</form>
<tags:pager pagerRange="10" pageSize="${pageSize}" totalPage="${totalPage}" curIndex="${pageIndex}" formId="queryForm"></tags:pager>
<table class="border">
<thead>
<tr>
<th width="100">用户名称</th>
<th width="500">操作内容</th>
<th width="200">操作时间</th>
</tr>
</thead>
<tbody>
<c:forEach items="${logList}" var="log">
<tr>
<td>${log.userName}</td>
<td>${log.result}</td>
<td>
<fmt:formatDate value="${log.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<tags:pager pagerRange="10" pageSize="${pageSize}" totalPage="${totalPage}" curIndex="${pageIndex}" formId="queryForm"></tags:pager>
</body>
展开全部
<%@ page language="java" import="java.util.*,java.sql.ResultSet" contentType="text/html; charset=utf-8"%>
<%@page import="com.dao.TrainingDAO"%>
<%@page import="com.db.DBUtil"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
ResultSet rs = null;
TrainingDAO dao = new TrainingDAO();
System.out.println("初始访问,加载全部数据");
//查询数据
rs = dao.find();
//设置每张网页显示三笔记录(每页显示的记录数)
int PageSize=30;
//设置欲显示的页数(初始页)
int ShowPage=1;
//ResultSet的记录笔数(总记录数)
int RowCount=0;
//ResultSet分页后的总数(总页数)
int PageCount=0;
try{
//将指标移至最后一条记录
rs.last();
//获取记录总数
RowCount=rs.getRow();
}catch(Exception ex){
out.print("查询数据库连接失败,请稍后重试。");
}
//计算显示的页数(关键)
PageCount=((RowCount%PageSize)==0?(RowCount/PageSize):(RowCount/PageSize)+1);
String ToPage=request.getParameter("ToPage");
//判断是否取得ToPage参数
if(ToPage!=null)
{
//取得指定显示的分页页数
ShowPage=Integer.parseInt(ToPage);
//下面的语句判断用户输入的页数是否正确
if(ShowPage>=PageCount)
{
ShowPage=PageCount;
}
else if(ShowPage<=0)
{
ShowPage=1;
}
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>培训查询</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">
.inp_text{
width:120px; height:20px; border:1px solid #004000; line-height:20px;
}
/*所有链接样式*/
a:link{font-size:14px;text-decoration:none; color:#333333;}
a:visited{font-size:14px; text-decoration:none; color:#333333;}
a:active{font-size:14px; text-decoration:none; color:#FF0000;}
a:hover{font-size:14px; text-decoration:none; color:#FF0000;}
body{font-size:12px; color:#000000;}
</style>
</head>
<body>
<div align="center">
<h3>培训信息查询</h3>
</div>
<form action="<%=path %>/query.jsp" method="post">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" style="font-size:12px;">
<tr>
<td width="80" height="30" align="center">姓名</td>
<td><input type="text" class="inp_text" id="t_name" name="t_name" /></td>
<td width="80" align="center">会员证号</td>
<td><input type="text" class="inp_text" id="t_card" name="t_card" /></td>
<td width="80" align="center">培训名称</td>
<td><input type="text" class="inp_text" style="width:200px;" id="t_pxname" name="t_pxname" /></td>
</tr>
<tr>
<td height="30" align="center">事务所名称</td>
<td><input type="text" class="inp_text" style="width:200px;" id="t_swname" name="t_swname" /></td>
<td align="center">年度</td>
<td>
<select id="t_time" name="t_time">
<option value="">-不限-</option>
<%
Calendar cal = new GregorianCalendar();
int currentYear = cal.get(Calendar.YEAR);
for(int i=0; i<20; i++){
%>
<option value="<%=currentYear %>"><%=currentYear %></option>
<%currentYear--;} %>
</select>
</td>
<td align="left" colspan="2">
<input type="submit" value="查询" />
</td>
</tr>
</table>
</form>
<table width="800" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#000000" style="font-size:12px; border-collapse:collapse;" >
<tr>
<th width="40" height="30" align="center">姓名</th>
<th width="30" align="center">性别</th>
<th width="30" align="center">年龄</th>
<th width="65" align="center">职务</th>
<th width="120" align="center">事务所名称</th>
<th width="55" align="center">学历</th>
<th width="98" align="center">会员证号</th>
<th width="30" align="center">是否通过</th>
<th width="115" align="center">培训名称</th>
<th width="40" align="center">培训费</th>
<th width="30" align="center">培训课时</th>
<th width="35" align="center">时间</th>
</tr>
<%
String pname = "";
String gender = "";
String age = "";
String post = "";
String mc = "";
String rank = "";
String member = "";
String isps = "";
String t_Name = "";
String t_money = "";
String t_times = "";
String t_year = "";
//计算欲显示页的第一笔记录位置
rs.absolute((ShowPage-1)*PageSize+1);
//while(rs.next()){
for(int i=1;i<=PageSize;i++){
pname = dao.formatString(rs.getString("pname"));
gender = dao.formatString(rs.getString("gender"));
age = dao.formatString(rs.getString("age"));
post = dao.formatString(rs.getString("post"));
mc = dao.formatString(rs.getString("mc"));
rank = dao.formatString(rs.getString("rank"));
member = dao.formatString(rs.getString("member"));
if(rs.getString("ispass").equals("1")){
isps = "是";
}else isps ="否";
t_Name = dao.formatString(rs.getString("t_Name"));
t_money = dao.formatString(rs.getString("t_money"));
t_times = dao.formatString(rs.getString("t_times"));
t_year = dao.formatString(rs.getString("t_year"));
%>
<tr>
<td height="35" align="center"><%=pname %></td>
<td align="center"><%=gender %></td>
<td align="center"><%=age %></td>
<td align="left"><%=post %></td>
<td align="left"><%=mc %></td>
<td align="center"><%=rank %></td>
<td align="center"><%=member %></td>
<td align="center"><%=isps %></td>
<td align="left"><%=t_Name %></td>
<td align="center"><%=t_money %></td>
<td align="center"><%=t_times %></td>
<td align="center"><%=t_year %></td>
</tr>
<%
if(!rs.next())
{
//跳出for循环
break;
}
}
DBUtil.closeConnection();
%>
</table>
<table width="540" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top:22px;font-size:14px; color:#000000;">
<tr>
<td valign="top">共有<%=RowCount %>条数据,当前在第<font style="font-size:14px;" color="red"><%=ShowPage %></font>页,共<%=PageCount %>页</td>
<td valign="top">
<a href="loadAll.jsp?ToPage=<%=1 %>">第一页</a>
<%
//判断当前是否在第一页,不是第一页,则显示到第一页与下一页的连接
if(ShowPage!=1)
{
%>
<a href="loadAll.jsp?ToPage=<%=ShowPage-1 %>">上一页</a>
<%
}
//判断是否在最后一页,是,则显示到最后一页和下一页
if(ShowPage!=PageCount)
{
%>
<a href="/training/loadAll.jsp?ToPage=<%=ShowPage+1 %>">下一页</a>
<a href="/training/loadAll.jsp?ToPage=<%=PageCount %>">最后一页</a>
<%
}
%>
</td>
<td valign="top">
<form action="loadAll.jsp" method="post" name="form1">
<input type="text" name="ToPage" value="<%=ShowPage %>" onkeyup="this.value=this.value.replace(/\D/g,'')"
onafterpaste="this.value=this.value.replace(/\D/g,'')" style="height:20px;width:30px">页
<a href="javascript:window.document.form1.submit();" style=" font-weight:bold;">GO</a>
</form></td>
</tr>
</table>
</body>
</html>
<%@page import="com.dao.TrainingDAO"%>
<%@page import="com.db.DBUtil"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
ResultSet rs = null;
TrainingDAO dao = new TrainingDAO();
System.out.println("初始访问,加载全部数据");
//查询数据
rs = dao.find();
//设置每张网页显示三笔记录(每页显示的记录数)
int PageSize=30;
//设置欲显示的页数(初始页)
int ShowPage=1;
//ResultSet的记录笔数(总记录数)
int RowCount=0;
//ResultSet分页后的总数(总页数)
int PageCount=0;
try{
//将指标移至最后一条记录
rs.last();
//获取记录总数
RowCount=rs.getRow();
}catch(Exception ex){
out.print("查询数据库连接失败,请稍后重试。");
}
//计算显示的页数(关键)
PageCount=((RowCount%PageSize)==0?(RowCount/PageSize):(RowCount/PageSize)+1);
String ToPage=request.getParameter("ToPage");
//判断是否取得ToPage参数
if(ToPage!=null)
{
//取得指定显示的分页页数
ShowPage=Integer.parseInt(ToPage);
//下面的语句判断用户输入的页数是否正确
if(ShowPage>=PageCount)
{
ShowPage=PageCount;
}
else if(ShowPage<=0)
{
ShowPage=1;
}
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>培训查询</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">
.inp_text{
width:120px; height:20px; border:1px solid #004000; line-height:20px;
}
/*所有链接样式*/
a:link{font-size:14px;text-decoration:none; color:#333333;}
a:visited{font-size:14px; text-decoration:none; color:#333333;}
a:active{font-size:14px; text-decoration:none; color:#FF0000;}
a:hover{font-size:14px; text-decoration:none; color:#FF0000;}
body{font-size:12px; color:#000000;}
</style>
</head>
<body>
<div align="center">
<h3>培训信息查询</h3>
</div>
<form action="<%=path %>/query.jsp" method="post">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" style="font-size:12px;">
<tr>
<td width="80" height="30" align="center">姓名</td>
<td><input type="text" class="inp_text" id="t_name" name="t_name" /></td>
<td width="80" align="center">会员证号</td>
<td><input type="text" class="inp_text" id="t_card" name="t_card" /></td>
<td width="80" align="center">培训名称</td>
<td><input type="text" class="inp_text" style="width:200px;" id="t_pxname" name="t_pxname" /></td>
</tr>
<tr>
<td height="30" align="center">事务所名称</td>
<td><input type="text" class="inp_text" style="width:200px;" id="t_swname" name="t_swname" /></td>
<td align="center">年度</td>
<td>
<select id="t_time" name="t_time">
<option value="">-不限-</option>
<%
Calendar cal = new GregorianCalendar();
int currentYear = cal.get(Calendar.YEAR);
for(int i=0; i<20; i++){
%>
<option value="<%=currentYear %>"><%=currentYear %></option>
<%currentYear--;} %>
</select>
</td>
<td align="left" colspan="2">
<input type="submit" value="查询" />
</td>
</tr>
</table>
</form>
<table width="800" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#000000" style="font-size:12px; border-collapse:collapse;" >
<tr>
<th width="40" height="30" align="center">姓名</th>
<th width="30" align="center">性别</th>
<th width="30" align="center">年龄</th>
<th width="65" align="center">职务</th>
<th width="120" align="center">事务所名称</th>
<th width="55" align="center">学历</th>
<th width="98" align="center">会员证号</th>
<th width="30" align="center">是否通过</th>
<th width="115" align="center">培训名称</th>
<th width="40" align="center">培训费</th>
<th width="30" align="center">培训课时</th>
<th width="35" align="center">时间</th>
</tr>
<%
String pname = "";
String gender = "";
String age = "";
String post = "";
String mc = "";
String rank = "";
String member = "";
String isps = "";
String t_Name = "";
String t_money = "";
String t_times = "";
String t_year = "";
//计算欲显示页的第一笔记录位置
rs.absolute((ShowPage-1)*PageSize+1);
//while(rs.next()){
for(int i=1;i<=PageSize;i++){
pname = dao.formatString(rs.getString("pname"));
gender = dao.formatString(rs.getString("gender"));
age = dao.formatString(rs.getString("age"));
post = dao.formatString(rs.getString("post"));
mc = dao.formatString(rs.getString("mc"));
rank = dao.formatString(rs.getString("rank"));
member = dao.formatString(rs.getString("member"));
if(rs.getString("ispass").equals("1")){
isps = "是";
}else isps ="否";
t_Name = dao.formatString(rs.getString("t_Name"));
t_money = dao.formatString(rs.getString("t_money"));
t_times = dao.formatString(rs.getString("t_times"));
t_year = dao.formatString(rs.getString("t_year"));
%>
<tr>
<td height="35" align="center"><%=pname %></td>
<td align="center"><%=gender %></td>
<td align="center"><%=age %></td>
<td align="left"><%=post %></td>
<td align="left"><%=mc %></td>
<td align="center"><%=rank %></td>
<td align="center"><%=member %></td>
<td align="center"><%=isps %></td>
<td align="left"><%=t_Name %></td>
<td align="center"><%=t_money %></td>
<td align="center"><%=t_times %></td>
<td align="center"><%=t_year %></td>
</tr>
<%
if(!rs.next())
{
//跳出for循环
break;
}
}
DBUtil.closeConnection();
%>
</table>
<table width="540" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top:22px;font-size:14px; color:#000000;">
<tr>
<td valign="top">共有<%=RowCount %>条数据,当前在第<font style="font-size:14px;" color="red"><%=ShowPage %></font>页,共<%=PageCount %>页</td>
<td valign="top">
<a href="loadAll.jsp?ToPage=<%=1 %>">第一页</a>
<%
//判断当前是否在第一页,不是第一页,则显示到第一页与下一页的连接
if(ShowPage!=1)
{
%>
<a href="loadAll.jsp?ToPage=<%=ShowPage-1 %>">上一页</a>
<%
}
//判断是否在最后一页,是,则显示到最后一页和下一页
if(ShowPage!=PageCount)
{
%>
<a href="/training/loadAll.jsp?ToPage=<%=ShowPage+1 %>">下一页</a>
<a href="/training/loadAll.jsp?ToPage=<%=PageCount %>">最后一页</a>
<%
}
%>
</td>
<td valign="top">
<form action="loadAll.jsp" method="post" name="form1">
<input type="text" name="ToPage" value="<%=ShowPage %>" onkeyup="this.value=this.value.replace(/\D/g,'')"
onafterpaste="this.value=this.value.replace(/\D/g,'')" style="height:20px;width:30px">页
<a href="javascript:window.document.form1.submit();" style=" font-weight:bold;">GO</a>
</form></td>
</tr>
</table>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询