标签:
主要SQL
select * from testTable where 1 limit ?,?
int pageSize=10;
//inputPage就是用户输入的要查询的是哪一页,
pstmt.setInt(1, (inputPage - 1) * pageSize);
pstmt.setInt(2, pageSize);
主要jsp
<body>
<ul>
<c:forEach items="${requestScope.tests}" var="p">
<li>用户名:${p.name}</li>
</c:forEach>
</ul>
<c:if test="${param.cur == 1}">
<a>首页</a>
<a>上一页</a>
</c:if>
<c:if test="${param.cur != 1}">
<a href="UserAction?cur=1">首页</a>
<a href="UserAction?cur=${param.cur - 1}">上一页</a>
</c:if>
<c:if test="${param.cur == requestScope.totalPage}">
<a>下一页</a>
<a>尾页</a>
</c:if>
<c:if test="${param.cur != requestScope.totalPage}">
<a href="UserAction?cur=${param.cur + 1}">下一页</a>
<a href="UserAction?cur=${requestScope.totalPage}">尾页</a>
</c:if>
<p>
当前第${param.cur}页 总共${requestScope.totalPage}页
</p>
</body>
标签:
原文地址:http://www.cnblogs.com/qiujiazhen/p/5372974.html