public String findAllProduct(Model model,@RequestParam(required=true,defaultValue="1") Integer page) {
PageHelper.startPage(page, 10);
List<ProductInfo> productList = productService.findAllProduct();
PageInfo<ProductInfo> p = new PageInfo<>(productList);model.addAttribute("page", p);
return "allProduct";
}
<div class="col-md-6">
<nav aria-label="Page navigation">
<ul class="pagination">
<li><a href="${pageContext.request.contextPath}/findAllProduct?page=1">首页</a></li>
<!--涓婁竴椤�-->
<li>
<c:if test="${page.hasPreviousPage}">
<a href="${pageContext.request.contextPath}/findAllProduct?page=${page.pageNum-1}" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</c:if>
</li>
<c:forEach items="${page.navigatepageNums}" var="page_num">
<c:if test="${page_num == page.pageNum}">
<li class="active"><a href="#">${page_num}</a></li>
</c:if>
<c:if test="${page_num != page.pageNum}">
<li><a href="${pageContext.request.contextPath}/findAllProduct?page=${page_num}">${page_num}</a></li>
</c:if>
</c:forEach>
<li>
<c:if test="${page.hasNextPage}">
<a href="${pageContext.request.contextPath}/findAllProduct?page=${page.pageNum+1}"
aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</c:if>
</li>
<li><a href="${pageContext.request.contextPath}/findAllProduct?page=${page.pages}">尾页</a></li>
</ul>
</nav>
</div>
引入bootstrap
如果没有pageinfo 注意引入jar包的版本