无法在jsp分页

时间:2016-04-21 07:34:59

标签: html jsp pagination

这是我的代码:

   <ul class = "pagination">
            <%--For displaying Previous link except for the 1st page --%>
            <c:if test="${model.currentPage != 0}">
                <li><a href="getEmployeesByPage?page=${model.currentPage - 1}">Previous</a></li>
            </c:if>

            <%--For displaying Page numbers.
            The when condition does not display a link for the current page--%>

                <c:forEach begin="0" end="${model.noOfPages}" var="i">
                    <c:if test="${model.noOfPages != 0}">
                        <c:choose>
                        <c:when test="${model.currentPage eq i}">
                            <li><b>${i+1}</b></li>
                        </c:when>
                        <c:otherwise>
                     <li><a href="getEmployeesByPage?page=${i}">${i+1}</a></li>
                        </c:otherwise>
                        </c:choose>
                    </c:if>
                 </c:forEach>


 <%--For displaying Next link --%>
            <c:if test="${model.currentPage lt model.noOfPages}">
                <li><a href="getEmployeesByPage?page=${model.currentPage + 1}">Next</a></li>
            </c:if>
        </ul>

这是一个简单的引导程序分页。我不希望当前页面成为链接并使其变为粗体。但结果是当前页码变为“不在列表中”,如下图所示。为什么呢?

image link

生成的源代码:

<ul class = "pagination">
    <li><a href="getEmployeesByPage?page=1">Previous</a></li>
    <li><a href="getEmployeesByPage?page=0">1</a></li>
    <li><a href="getEmployeesByPage?page=1">2</a></li>
    <li><b>3</b></li>
    <li><a href="getEmployeesByPage?page=3">4</a></li>
    <li><a href="getEmployeesByPage?page=3">Next</a></li>    
</ul>

1 个答案:

答案 0 :(得分:0)

尝试更改

<li><b>${i+1}</b></li>

<li class="active"><a href="#">${i+1}</a></li>

请勿删除class="pagination"中的ul

查看pagination page of bootstrap并确保您生成的代码与示例中的代码类似。

这有用吗?