new363.java
package pack03;
import com.sun.rowset.CachedRowSetImpl;
public class new363
{
/**
* 存储表中全部记录集对象
* 每页显示记录数
* 分页后的总页数
* 当前页
* 显示当前页内容
* */
private CachedRowSetImpl rowSet = null;
private int pageSize = 10;
private int pageAllCount = 0;
private int showPage = 1;
private StringBuffer presentPageResult;
public CachedRowSetImpl getRowSet()
{
return rowSet;
}
public void setRowSet(CachedRowSetImpl rowSet)
{
this.rowSet = rowSet;
}
public int getPageSize()
{
return pageSize;
}
public void setPageSize(int pageSize)
{
this.pageSize = pageSize;
}
public int getPageAllCount()
{
return pageAllCount;
}
public void setPageAllCount(int pageAllCount)
{
this.pageAllCount = pageAllCount;
}
public int getShowPage()
{
return showPage;
}
public void setShowPage(int showPage)
{
this.showPage = showPage;
}
public StringBuffer getPresentPageResult()
{
return presentPageResult;
}
public void setPresentPageResult(StringBuffer presentPageResult)
{
this.presentPageResult = presentPageResult;
}
}
new364.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>bootstrap + jsp 的使用</title>
<link rel="stylesheet" href="../other/boot/css/bootstrap.min.css">
<script type="text/javascript" src="../other/jQuery/jQuery-3.4.1.js"></script>
<script type="text/javascript" src="../other/boot/js/bootstrap.min.js"></script>
</head>
<body>
<%@include file="new348.jsp"%>
<div class="container-fluid">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<form class="form-horizontal" method="post" action="new367">
<div class="form-group">
<label for="showPage" class="col-sm-2 control-label">分页显示全体会员:</label>
<div class="col-sm-10">
<input type="hidden" class="form-control" id="showPage" name="showPage" value="1" size="6">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">显示</button>
</div>
</div>
</form>
<form class="form-horizontal" method="get" action="new367">
<div class="form-group">
<label for="loginName" class="col-sm-2 control-label">输入要查找的会员名:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="loginName" name="loginName">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">显示</button>
</div>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
new365.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="pack03.new363" %>
<jsp:useBean id="show" type="pack03.new363" scope="session"/>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>bootstrap + jsp 的使用</title>
<link rel="stylesheet" href="../other/boot/css/bootstrap.min.css">
<script type="text/javascript" src="../other/jQuery/jQuery-3.4.1.js"></script>
<script type="text/javascript" src="../other/boot/js/bootstrap.min.js"></script>
</head>
<body>
<%@include file="new348.jsp"%>
<div class="container-fluid">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<p>显示会员信息</p>
<br>每页最多显示<jsp:getProperty name="show" property="pageSize"/>条信息
<br>当前显示第<strong><jsp:getProperty name="show" property="showPage"/></strong>页,共有<strong><jsp:getProperty name="show" property="pageAllCount"/></strong>页。
<br>当前显示的内容是:
<table class="table table-bordered">
<tr>
<th>编号</th>
<th>会员名</th>
<th>性别</th>
<th>年龄</th>
<th>电话</th>
<th>邮箱</th>
<th>简介</th>
<th>图片</th>
</tr>
<jsp:getProperty name="show" property="presentPageResult"/>
</table>
<br>单击“前一页” 或 “下一页” 按钮查看信息
<table>
<tr>
<td>
<form action="new367" method="post">
<input type="hidden" name="showPage" value="<%= show.getShowPage() - 1 %>">
<input type="submit" name="g" value="前一页">
</form>
</td>
</tr>
<tr>
<td>
<form action="new367" method="post">
<input type="hidden" name="showPage" value="<%= show.getShowPage() + 1 %>">
<input type="submit" name="g" value="后一页">
</form>
</td>
</tr>
<tr>
<td>
<form action="new367" method="post">
输入页码:<input type="text" name="showPage">
<input type="submit" name="g" value="提交">
</form>
</td>
</tr>
</table>
</div>
</div>
</div>
</body>
</html>