jsp页面简单分页

    <%-- <div align="center" style="margin-top:30px;">当前第:${param.page }页;共:${ param.totalPage}页<a href="getUserListServlet?page=1">首页</a>
  <c:if test="${param.page != 1}"><a href="getUserListServlet?page=${param.page-1}">上一页</a></c:if><c:if test="${param.page ==1}">上一页</c:if>
     <c:if test="${param.page != param.totalPage}"><a href="getUserListServlet?page=${param.page+1}">下一页</a></c:if><c:if test="${param.page == param.totalPage}">下一页</c:if>
     <a href="getUserListServlet?page=${param.totalPage}">尾页</a></div> --%>
        <div align="center" style="margin-top: 30px;">
            当前第:${param.page}页,共${param.totalPage}页
            <a href="SeleServlet?page=1">首页</a>
            <c:if test="${param.page != 1}">
                <a href="SeleServlet?page=${param.page - 1}">上一页</a>
            </c:if>
            <c:if test="${param.page == 1}">上一页</c:if>
            <c:if test="${param.page != param.totalPage}">
                <a href="SeleServlet?page=${param.page + 1}">下一页</a>
            </c:if>
            <c:if test="${param.page == param.totalPage}">下一页</c:if>
            <a href="SeleServlet?page=${param.totalPage}">尾页</a>
        </div>

转化为项目代码

 <div  style="margin: 0 0 10px 0 ;color: red;text-align:center;line-height: 30px;">
            Current :The ${currentPage} page,&nbsp;&nbsp;&nbsp;Total: ${totalPage} pages,&nbsp;&nbsp;&nbsp;
            <a href="<s:url namespace="/business" action="search?gosearch=%{gosearch}&&categoryIdHeader=%{categoryIdHeader}&&currentPage=1"/>">FirstPage</a>&nbsp;&nbsp;&nbsp;
            <c:if test="${currentPage != 1}">
                <a href="<s:url namespace="/business" action="search?gosearch=%{gosearch}&&categoryIdHeader=%{categoryIdHeader}&&currentPage=%{currentPage - 1}"/>">Previous</a>&nbsp;&nbsp;&nbsp;
            </c:if>
            <c:if test="${currentPage == 1}">Previous&nbsp;&nbsp;&nbsp;</c:if>
            <s:iterator value="totalPages" status="page">
                <a href="<s:url namespace="/business" action="search?gosearch=%{gosearch}&&categoryIdHeader=%{categoryIdHeader}&&currentPage=%{#page.index+1}"/>"><s:property value="#page.index+1"/></a>&nbsp;
            </s:iterator>
            <c:if test="${currentPage != totalPage}">
                <a href="<s:url namespace="/business" action="search?gosearch=%{gosearch}&&categoryIdHeader=%{categoryIdHeader}&&currentPage=%{currentPage + 1}"/>">Next</a>&nbsp;&nbsp;&nbsp;
            </c:if>
            <c:if test="${currentPage == totalPage}">Next</c:if>&nbsp;&nbsp;&nbsp;
            <a href="<s:url namespace="/business" action="search?gosearch=%{gosearch}&&categoryIdHeader=%{categoryIdHeader}&&currentPage=%{totalPage}"/>">LastPage</a>&nbsp;&nbsp;&nbsp;
        </div>

需要传入的参数currentPage; totalPage;totalPages;

原文地址:https://www.cnblogs.com/cuiyf/p/2964608.html