【问题标题】:How can I keep my current page inside the Bootstrap ul?如何将当前页面保留在 Bootstrap ul 中?
【发布时间】:2018-05-13 14:51:00
【问题描述】:

我正在使用 Bootstrap 使使用 JSTL 标签创建的分页看起来更好。出于某种原因,当前页码位于引导样式之外的右侧。谁能告诉我为什么我的代码会这样做以及如何解决它?谢谢!

    <nav aria-label="Page navigation">
        <ul class="pagination">
            <li><c:if test="${currentPage != 1}">
                    <a href="event.do?page=${currentPage - 1}" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </c:if></li>
            <c:forEach begin="1" end="${noOfPages}" var="i">
                <c:choose>
                    <c:when test="${currentPage eq i}">
                        <li>${i}</li>
                    </c:when>
                    <c:otherwise>
                        <li><a href="event.do?page=${i}">${i}</a></li>
                    </c:otherwise>
                </c:choose>
            </c:forEach>
            <li><c:if test="${currentPage lt noOfPages}">
                    <a href="event.do?page=${currentPage + 1}" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </c:if></li>
        </ul>
        </nav>

【问题讨论】:

  • 欢迎来到 Stack Overflow,您的问题应包含a Minimal, Complete, and Verifiable example
  • 我认为标记看起来是正确的(我不熟悉 JSTL),但作为测试,我会尝试将您当前的页码包装在 &lt;a href="#"&gt;&lt;/a&gt; 中,看看是否有区别。所以应该是&lt;li&gt;&lt;a href="#"&gt;${i}&lt;/a&gt;&lt;/li&gt;
  • 是的!有效!非常感谢!
  • 好的,我会把它作为答案发布。

标签: css pagination jstl


【解决方案1】:

href="#" 将您当前的页码包裹在一个锚标记中。

像这样:

&lt;li&gt;&lt;a href="#"&gt;${i}&lt;/a&gt;&lt;/li&gt;

我想可能是因为分页的引导样式需要标记ul &gt; li &gt; a

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-01
    • 1970-01-01
    相关资源
    最近更新 更多