当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Passing dynamic parameters in FOREACH loop in JSTL in JSP

问题描述:

I am displaying certain record on a jsp page using a FOREACH loop. it takes parameters begin and end. i want to pass dynamic parameters in them

like this:

<%! int i=5; int j=10; %>

<c:ForEach var="ad" item="Products" begin="i" end="j">

<table>

<tr>

<td>${ad.id}</td>

<td>${ad.name}</td>

</tr>

</table>

网友答案:

You would not use a declaration block to set the values but rather set them in the controller with request.setAttribute(). Then:

<c:forEach var="ad" items="${Products}" begin="${i}" end="${j}">
分享给朋友:
您可能感兴趣的文章:
随机阅读: