Skip to content

Instantly share code, notes, and snippets.

@john-eevee
Created September 24, 2014 02:20
Show Gist options
  • Select an option

  • Save john-eevee/7ad9373a84af205b9fd9 to your computer and use it in GitHub Desktop.

Select an option

Save john-eevee/7ad9373a84af205b9fd9 to your computer and use it in GitHub Desktop.
<c:set var="firstUrl" value="${pageContext.request.contextPath}/warehouse/parts"/>
<c:set var="lastUrl" value="${pageContext.request.contextPath}/warehouse/parts?page=${totalPages - 1}"/>
<c:set var="prevUrl" value="${pageContext.request.contextPath}/warehouse/parts?page=${currentIndex - 1}"/>
<c:set var="nextUrl" value="${pageContext.request.contextPath}/warehouse/parts?page=${currentIndex + 1}"/>
<div class="pagination">
<ul class="pagination pagination-sm">
<c:choose>
<c:when test="${currentIndex == 1}">
<li class="disabled"><a href="#">&lt;&lt;</a></li>
<li class="disabled"><a href="#">&lt;</a></li>
</c:when>
<c:otherwise>
<li><a href="${firstUrl}">&lt;&lt;</a></li>
<li><a href="${prevUrl}">&lt;</a></li>
</c:otherwise>
</c:choose>
<c:forEach var="pos" begin="${beginIndex}" end="${endIndex}">
<c:url var="pageUrl" value="${pageContext.request.contextPath}/warehouse/parts?page=${pos-1}"/>
<c:choose>
<c:when test="${pos == currentIndex}">
<li class="active"><a href="${pageUrl}"><c:out value="${pos}"/></a></li>
</c:when>
<c:otherwise>
<li><a href="${pageUrl}"><c:out value="${pos}"/></a></li>
</c:otherwise>
</c:choose>
</c:forEach>
<c:choose>
<c:when test="${currentIndex == totalPages}">
<li class="disabled"><a href="#">&gt;</a></li>
<li class="disabled"><a href="#">&gt;&gt;</a></li>
</c:when>
<c:otherwise>
<li><a href="${nextUrl}">&gt;</a></li>
<li><a href="${lastUrl}">&gt;&gt;</a></li>
</c:otherwise>
</c:choose>
</ul>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment