问题描述
我需要在JSTL / EL中为循环(在Java上下文中)表示下面的。
<$ p $ (int i = 6; i< = 15; i ++){
System.out.print(i +\ t);
$ b $ p
$ b $ p
$ b
6 7 8 9 10 11 12 13 14 15
我如何在JSTL / EL中做同样的事情?我对此没有确切的想法。
< c:forEach begin =6end =15varStatus =环>
< c:out value =$ {loop.count}/>
< / c:forEach>
显然会显示以下输出。
1 2 3 4 5 6 7 8 9 10
这不是我想要的。我需要在 6
和 15
之间显示数字(即在指定范围之间)。我需要把这样一个概念来实现分页在我的Web应用程序。我可以用EL做这个吗?
\t
in这个语句 System.out.print(i +\ t);
不重要。
< c:forEach begin =6end =方案
15var =val>
< c:out value =$ {val}/>
< / c:forEach>
或以下内容:
< c:forEach begin =6end =15varStatus =loop>
< / c:forEach>
或以下内容:
< c:forEach begin =6end =15varStatus =loop>
< c:out value =$ {loop.index}/>
< / c:forEach>
I need to represent the following for
loop (in Java context) in JSTL/EL.
for (int i = 6; i <= 15; i++) {
System.out.print(i+"\t");
}
It would display the following output.
6 7 8 9 10 11 12 13 14 15
How can I do the same in JSTL/EL? I have no precise idea about it. I'm just trying the following.
<c:forEach begin="6" end="15" varStatus="loop">
<c:out value="${loop.count}"/>
</c:forEach>
and it would obviously display the following output.
1 2 3 4 5 6 7 8 9 10
It's not that I want. I need to display numbers between 6
and 15
(i.e between the specified range). I need to put such a concept to implement paging in my web application. Can I do this using EL?
\t
in this statement System.out.print(i+"\t");
is not significant.
The following should work:
<c:forEach begin="6" end="15" var="val">
<c:out value="${val}"/>
</c:forEach>
Or the following:
<c:forEach begin="6" end="15" varStatus="loop">
<c:out value="${loop.current}"/>
</c:forEach>
Or the following:
<c:forEach begin="6" end="15" varStatus="loop">
<c:out value="${loop.index}"/>
</c:forEach>
这篇关于在JSTL / EL中表示一个简单的for循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!