Example 1:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<table border="1">
<c:forTokens var="element" items="t1;t2/t3;t4/t5;t6,t7,t8;t9" delims=";,/" varStatus="c">
<tr>
<td>${c.count}</td>
<td>${element}</td>
</tr>
</c:forTokens>
</table>
prints,
1 | t1 |
2 | t2 |
3 | t3 |
4 | t4 |
5 | t5 |
6 | t6 |
7 | t7 |
8 | t8 |
9 | t9 |
Example 2:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="testString" scope="application" value="t1;t2/t3;t4/t5/t6,t7,t8;t9" />
<table border="1">
<c:forTokens var="element" items="t1;t2/t3;t4/t5;t6,t7,t8;t9" delims=";,/" varStatus="c" begin="1" end="7" step="2">
<tr>
<td>${c.count}</td>
<td>${element}</td>
</tr>
</c:forTokens>
</table>
prints,
1 | t2 |
2 | t4 |
3 | t6 |
4 | t8 |
No comments:
Post a Comment