Tom Wally Tom Wally - 1 year ago 79
Java Question

Override variables in JSTL

I'm trying to make pagination.

I have some variable


<c:set var="get_page_num"/>

<spring:url value="" var="pageurl">
<spring:param name="page" value="${get_page_num}" />
<spring:param name="size" value="${page.size}" />

After that, I'm trying to generate the url:

<li><a href="${pageurl}">7</a></li>
<li><a href="${pageurl}">8</a></li>

How can I put 7 or 8 value (number of page) to
variable. I need to override it.

Answer Source

Values 7,8 are already generated, you can get em only with javascript.

Use parameter in the url

<li><a href="${pageurl}?get_page_num=7">7</a></li> 

In more sophisticated code you can write

<spring:url value="" var="pageurl" />
<c:forEach begin="1" end="${page.size}" varStatus="status">
 <c:if test="${get_page_num == status.current}">
 <c:if test="${get_page_num != status.current}">
   <li><a href="${pageurl}?get_page_num=${status.current}">${status.current}&nbsp;</a></li>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download