









<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'productinfo.jsp' starting page</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">
-->
</head>
<body>
<h1>欢迎来到商品信息管理平台</h1>
<h3>
<a href="${pageContext.request.contextPath}/productfindallservlet">查询所有商品</a>
<a
href="${pageContext.request.contextPath}/productfindbypageservlet?currentpage=1">分页查询商品</a>
</h3>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'prolist.jsp' starting page</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">
-->
<script type="text/javascript"
src="${pageContext.request.contextPath}/html/jquery-3.2.1.js"></script>
<script type="text/javascript">
function addpage() {//在添加商品时页面跳转到商品添加页面
window.location.href = "${pageContext.request.contextPath}/html/addproduct.jsp";/* 页面跳转 */
}
function del(pid) {//商品删除时弹框问
var v = window.confirm("确定要删除吗?");
if (v) {
window.location.href = "${pageContext.request.contextPath}/deleteproductservlet?pid="
+ pid;/* 页面跳转 */
}
}
$(function() {//实现复选框的全选
$("#selectall").click(function() {
$(":checkbox").prop("checked", this.checked);
});
});
function delall() {//删除所有的函数
document.getElementById("form1").submit();//表单默认提交给删除所有的页面
}
function search() {//查询的函数
//获得文本框的值
var pname = document.getElementById("pname").value;
//获得表单
document.getElementById("form1").action = "${pageContext.request.contextPath}/productsearchservlet";//此时修改表单提交路径
//表单提交
document.getElementById("form1").submit();
}
</script>
</head>
<body>
<h1>商品的列表页面</h1>
<form id="form1"
action="${pageContext.request.contextPath}/productdeleteallservlet"
" method="post">
<!-- 表单提交给删除所有的servlet -->
<table border="1" width="800">
<tr>
<td colspan="4">名称<input type="text" name="pname" id="pname" />
<input type="button" value="查询" onclick="search()">
<input type="button" value="添加" onclick="addpage()" /> <input
type="button" value="删除" onclick="delall()" />
<!-- 删除所有 -->
<tr>
<td><input type="checkbox" id="selectall" />
<td>商品序号
<td>商品名称
<td>商品价格
<td>操作
</tr>
<c:forEach var="l" items="${list}">
<!-- 对传来的list进行遍历 -->
<tr>
<td><input type="checkbox" name="ids" value="${l.pid}">
<td>${l.pid }
<td>${l.pname}
<td>${l.market_price}
<td><a
href="${pageContext.request.contextPath}/editproductservlet?pid=${l.pid}">修改</a> <!-- 商品的修改 ,传入pid-->
<a onclick="del('${l.pid}')">删除</a>
<!-- 商品的删除,传入pid-->
</tr>
</c:forEach>
</table>
</form>
</body>
</html>
package product;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class productfindallservlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/*调用业务层查找*/
try{
productservice ps=new productservice();
List<product>list=ps.findall();
//数据保存传给jsp页面
request.setAttribute("list", list);
//页面跳转
request.getRequestDispatcher("/html/prolist.jsp").forward(request, response);
}catch(Exception e){
e.printStackTrace();
throw new RuntimeException();
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
/*业务层查询所有商品的方法*/
public List<product> findall() throws SQLException {
// TODO Auto-generated method stub
productdao pd=new productdao();
return pd.findall();
}
public List<product> findall() throws SQLException {
// DAO中查询所有商品
QueryRunner qr=new QueryRunner(c3p0tool.getDataSource());
String sql="select *from product order by pdate desc";
List<product>list=qr.query(sql, new BeanListHandler<product>(product.class));
return list;
}
<%@page import="utils.UUIDutils"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'addproduct.jsp' starting page</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">
-->
</head>
<body>
<%
String token = UUIDutils.getUUID();//产生一个随机序号
session.setAttribute("token", token);//将随机序号存储到session的token中
%>
<h1>添加商品的页面</h1>
<form action="${pageContext.request.contextPath}/productaddservlet"
method="post">
<table border="1" width="600">
<tr>
<td>商品名称
<td><input type="text" name="pname">
</tr>
<tr>
<td>商品市场价格
<td><input type="text" name="market_price">
</tr>
<tr>
<td>
</tr>
</table>
<input type="hidden" name="token" value="<%=token%>"> <input
type="submit" value="确定">//设置隐藏标签保存token
</form>
</body>
</html>
package utils;
import java.util.UUID;
//产生随机的字符串
public class UUIDutils {
public static String getUUID(){
return UUID.randomUUID().toString();
}
}
package product;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.Date;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import utils.UUIDutils;
public class productaddservlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/*
*
* 添加商品的servlet
*/
request.setCharacterEncoding("UTF-8");
//判断是否为重复提交
String token1=(String) request.getSession().getAttribute("token");//获得session中的token
String token2=request.getParameter("token");//获得表单提交的token
request.getSession().removeAttribute("token");//移除session中的token
if(!token2.equals(token1)){
request.setAttribute("msg", "亲,不能重复提交了哦");
request.getRequestDispatcher("/html/msg.jsp").forward(request, response);//跳转到提示页面
return;
}
Map<String,String>map=request.getParameterMap();//将表单中的所有数封装在map中
//封装数据
product p=new product();
try {
BeanUtils.populate(p, map);//将map封装成product对象,map<product
p.setPdate(new Date());
p.setPid(UUIDutils.getUUID());
/*调用业务层*/
productservice ps=new productservice();
try {
ps.save(p);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.getRequestDispatcher("/productfindallservlet").forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
public void save(product p) throws SQLException {
/*业务层保存商品*/
productdao pd=new productdao();
pd.save(p);
}
public void save(product p) throws SQLException {
// DAO中保存商品的方法
QueryRunner qr=new QueryRunner(c3p0tool.getDataSource());
String sql="insert into product values(?,?,?,?)";
qr.update(sql, p.getPid(),p.getPname(),p.getMarket_price(),p.getPdate());
}
package product;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class editproductservlet extends HttpServlet {
/*商品编辑的servlet*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//接收数据pid
String pid=request.getParameter("pid");
productservice ps=new productservice();
try {
product p=ps.findbyid(pid);//通过id查找到这个商品
p.setPid(pid);
request.setAttribute("product", p);//将查询到的product保存起来
request.getRequestDispatcher("/html/editproduct.jsp").forward(request, response);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet( request, response);
}
}
public product findbyid(String pid) throws SQLException {
/*业务层根据ID来查找商品*/
productdao pd=new productdao();
return pd.findbyid(pid);
}
public product findbyid(String pid) throws SQLException {
// DAO中通过pid来查询商品
QueryRunner qr=new QueryRunner(c3p0tool.getDataSource());
String sql="select *from product where pid=?";
product p=qr.query(sql, new BeanHandler<product>(product.class),pid);
return p;
}
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'editproduct.jsp' starting page</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">
-->
</head>
<body>
<h1>修改商品的页面</h1>
<form action="${pageContext.request.contextPath}/updateproductservlet"
method="post">
<table border="1" width="600">
<tr>
<td>商品名称
<td><input type="text" name="pname" value="${product.pname}">
</tr>
<tr>
<td>商品市场价格
<td><input type="text" name="market_price"
value="${product.market_price}">
</tr>
<tr>
<td>
</tr>
</table>
<input type="hidden" name="pid" value="${product.pid}"> <input
type="submit" value="确定">
</form>
</body>
</html>
package product;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.Date;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
public class updateproductservlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//接收数据
request.setCharacterEncoding("UTF-8");
Map<String,String>map=request.getParameterMap();//将接收的的参数封装在map中
product p=new product();
try {
BeanUtils.populate(p, map);//将map封装在product中
p.setPdate(new Date());
//调用业务层处理数据
productservice ps=new productservice();
ps.update(p);
request.getRequestDispatcher("/productfindallservlet").forward(request, response);
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
public void update(product p) throws SQLException {
// 业务层修改商品的方法
productdao pd=new productdao();
pd.update(p);
}
public void update(product p) throws SQLException {
// DAO中修改商品
QueryRunner qr=new QueryRunner(c3p0tool.getDataSource());
String sql="update product set pname=?,market_price=? where pid=?";
qr.update(sql,p.getPname(),p.getMarket_price(),p.getPid());
}
package product;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class deleteproductservlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//商品删除传入pid
String pid=request.getParameter("pid");
productservice ps=new productservice();
try {
ps.delete(pid);
request.getRequestDispatcher("/productfindallservlet").forward(request, response);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
public void delete(String pid) throws SQLException {
// 业务层删除商品的方法
productdao pd=new productdao();
pd.delete(pid);
}
public void delete(String pid) throws SQLException {
// DAO中删除商品的方法
QueryRunner qr=new QueryRunner(c3p0tool.getDataSource());
String sql="delete from product where pid=?";
qr.update(sql,pid);
}
package product;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class productdeleteallservlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//接收多个ID
String[] ids=request.getParameterValues("ids");
productservice ps=new productservice();
ps.deleteall(ids);
request.getRequestDispatcher("/productfindallservlet").forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet( request, response);
}
}
public void deleteall(String[] ids) {
// 业务层删除所有商品的方法
Connection con = c3p0tool.getConnection();
try {
con.setAutoCommit(false);//调用事物同时删除
productdao pd=new productdao();
for(String id:ids){
pd.delete(con,id);
}
DbUtils.commitAndCloseQuietly(con);//提交
} catch (Exception e) {
// 回滚
DbUtils.rollbackAndCloseQuietly(con);
}
}
public void delete(Connection con, String id) throws SQLException {
// TODO Auto-generated method stub
QueryRunner qr=new QueryRunner();
String sql="delete from product where pid=?";
qr.update(con,sql,id);
}
public void delete(Connection con, String id) throws SQLException {
// TODO Auto-generated method stub
QueryRunner qr=new QueryRunner();
String sql="delete from product where pid=?";
qr.update(con,sql,id);
}
package product;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class productsearchservlet extends HttpServlet {
/**
* 商品的模糊查询
*/
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//接收数据
request.setCharacterEncoding("UTF-8");
String pname=request.getParameter("pname");
productservice ps=new productservice();
try {
List<product>list=ps.search(pname);//通过pname来查询
request.setAttribute("list", list);//将list保存传给prolist.jsp
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.getRequestDispatcher("/html/prolist.jsp").forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
public List<product> search(String pname) throws SQLException {
// 业务层查询商品
productdao pd=new productdao();
return pd.search(pname);
}
public List<product> search(String pname) throws SQLException {
// DAO中查询商品
QueryRunner qr=new QueryRunner(c3p0tool.getDataSource());
String sql="select *from product where pname like ? order by pdate desc";
List<product> p=qr.query(sql, new BeanListHandler<product>(product.class),"%"+pname+"%");
return p;
}
package product;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class productfindbypageservlet extends HttpServlet {
/*
* 分页查询商品的servlet
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//接收数据
int currentpage=Integer.parseInt(request.getParameter("currentpage"));
//调用业务层处理数据
productservice ps=new productservice();
try {
pagebean pb=ps.findbypage(currentpage);
//将写好的数据保存起来
request.setAttribute("pb", pb);
request.getRequestDispatcher("/html/productpage.jsp").forward(request, response);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
package product;
import java.util.List;
/*
*封装分页数据的JAVABEAN
*/
public class pagebean {
private int currpage;//当前页数
private int totalcount;//总记录数
private int pagesize;//每页的记录数
private List<product>list;//每页的数据集合
private int totalpage;
public int getCurrpage() {
return currpage;
}
public void setCurrpage(int currpage) {
this.currpage = currpage;
}
public int getTotalcount() {
return totalcount;
}
public void setTotalcount(int totalcount) {
this.totalcount = totalcount;
}
public int getPagesize() {
return pagesize;
}
public void setPagesize(int pagesize) {
this.pagesize = pagesize;
}
public List<product> getList() {
return list;
}
public void setList(List<product> list) {
this.list = list;
}
public int getTotalpage() {
return totalpage;
}
public void setTotalpage(int totalpage) {
this.totalpage = totalpage;
}
}
public pagebean findbypage(int currentpage) throws SQLException {
// 业务层分页查询
pagebean pb=new pagebean();
//设置当前页数
pb.setCurrpage(currentpage);
//设置每页显示的最大记录
int pagesize=3;
pb.setPagesize(pagesize);
productdao pd=new productdao();
//将开始序号和pagesize传入DAO中
int begin=(currentpage-1)*pagesize;
List<product>list=pd.findbypage(begin,pagesize);//DAO中返回一个list集合
//设置list集合
pb.setList(list);
//设置总序列数
int totalcount=pd.findcount();
pb.setTotalcount(totalcount);
double tc=(double)totalcount;
double ps=(double)pagesize;
//设置总页数
int totalpage=(int) Math.ceil(tc/ps);
pb.setTotalpage(totalpage);
return pb;
}
public List<product> findbypage(int begin, int pagesize) throws SQLException {
// 显示当前页的信息
QueryRunner qr=new QueryRunner(c3p0tool.getDataSource());
String sql="select * from product order by pdate desc limit ?,?";
List<product> list = qr.query(sql, new BeanListHandler<product>(product.class),begin,pagesize);
return list;
}
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'prolist.jsp' starting page</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">
-->
<script type="text/javascript"
src="${pageContext.request.contextPath}/html/jquery-3.2.1.js"></script>
<script type="text/javascript">
$(function() {
$("#selectall").click(function() {
$("#ids").prop("checked", this.checked);
});
});
</script>
<script type="text/javascript">
function addpage() {
window.location.href = "${pageContext.request.contextPath}/html/addproduct.jsp";/* 页面跳转 */
}
function del(pid) {
var v = window.confirm("确定要删除吗?");
if (v) {
window.location.href = "${pageContext.request.contextPath}/deleteproductservlet?pid="
+ pid;/* 页面跳转 */
}
}
function delall() {
document.getElementById("form1").submit();
}
function search() {
//获得文本框的值
var pname = document.getElementById("pname").value;
//获得表单
document.getElementById("form1").action = "${pageContext.request.contextPath}/productsearchservlet";
//表单提交
document.getElementById("form1").submit();
}
</script>
<script type="text/javascript"
src="${pageContext.request.contextPath}/html/jquery-3.2.1.js"></script>
<script type="text/javascript">
$(function() {
$("#selectall").click(function() {
$(":checkbox").prop("checked", this.checked);
});
});
</script>
</head>
<body>
<h1>商品的列表页面</h1>
<form id="form1"
action="${pageContext.request.contextPath}/productdeleteallservlet"
" method="post">
<table border="1" width="800">
<tr>
<td colspan="4">名称<input type="text" name="pname" id="pname" />
<input type="button" value="查询" onclick="search()">
<input type="button" value="添加" onclick="addpage()" /> <input
type="button" value="删除" onclick="delall()" />
<tr>
<td><input type="checkbox" id="selectall" />
<td>商品序号
<td>商品名称
<td>商品价格
<td>操作
</tr>
<c:forEach var="l" items="${pb.list}">
<tr>
<td><input type="checkbox" name="ids" value="${l.pid}">
<td>${l.pid }
<td>${l.pname}
<td>${l.market_price}
<td><a
href="${pageContext.request.contextPath}/editproductservlet?pid=${l.pid}">修改</a>
<a onclick="del('${l.pid}')">删除</a>
</tr>
</c:forEach>
<tr>
<td colspan="4" align="center">
第${pb.currpage}/${pb.totalpage}页
总记录数${pb.totalcount} 当前页面记录数为${pb.pagesize}
<c:if test="${pb.currpage!=1}">
<!-- 是首页 -->
<a
href="${pageContext.request.contextPath}/productfindbypageservlet?currentpage=1">[首页]</a>
<a
href="${pageContext.request.contextPath}/productfindbypageservlet?currentpage=${pb.currpage-1}">[上一页]</a>
</c:if> <c:forEach var="i" begin="1" end="${pb.totalpage}">
<c:if test="${pb.currpage!=i}">
<a
href="${pageContext.request.contextPath}/productfindbypageservlet?currentpage=${i}">${i}</a>
</c:if>
<c:if test="${pb.currpage==i}">
<!-- 当前页数不是超链接形式 -->
${i}
</c:if>
</c:forEach> <c:if test="${pb.currpage!=pb.totalpage}">
<!-- 是尾页 -->
<a
href="${pageContext.request.contextPath}/productfindbypageservlet?currentpage=${pb.currpage+1}">[下一页]</a>
<a
href="${pageContext.request.contextPath}/productfindbypageservlet?currentpage=${pb.totalpage}">[尾页]</a>
</c:if>
</tr>
</table>
</form>
</body>
</html>