JSTL 比教时间

How to deal with break in jsp
Sometimes, we have to deal with the break in a for iteration.
In jstl, there's no break logic. But we can achieve that by composing the jstl tags.
The following is an example:
Code:

for (int i=pageVariable; i<= showThisMuch;i++) {
if (j==10){
break;
}
}

Code:

<c:forEach varStatus="status" begin="${pageVariable}" end="${showThisMuch}">
<c:if test="${j<10}">

</c:if>
</c:forEach>

Thanks for Bruce's advice
Last edited by Ben; 2009-01-21 at 01:22 AM.
Reply With Quote Multi-Quote This Message Quick reply to this message
Ben
View Public Profile
Send a private message to Ben
Send email to Ben
Find all posts by Ben
Add Ben to Your Contacts
#9 Report Post
Old 2009-01-21, 11:45 AM
osagie osagie is offline
Member

Join Date: Jan 2009
Posts: 80
Default
To compare dates, try this

Code:

Date: <fmt:formatDate value="${now}" dateStyle="full" />
Number: <fmt:formatNumber value="${now.time}" />
StartDate:<fmt:formatDate value="${startDate}" dateStyle="full" />
Start Number:<fmt:formatNumber value="${startDate.time}" />
<c:set var="checkTime1"><fmt:formatNumber value="${startDate.time}" /></c:set>
<c:set var="checkTime2"><fmt:formatNumber value="${now.time}" /></c:set>
<c:if test="${checkTime1 < checkTime2}"> Start Date is Less than today's date </c:if>
<c:if test="${checkTime1 == checkTime1}"> Same dates </c:if>

Reply With Quote Multi-Quote This Message Quick reply to this message
osagie
View Public Profile
Send a private message to osagie
Send email to osagie
Find all posts by osagie
Add osagie to Your Contacts
#10 Report Post
Old 2009-01-21, 09:06 PM
Ben Ben is offline
Member

Join Date: Jan 2009
Posts: 78
Default
In some aspects, EL expressions are different form java expressions
in java
Code:

1/3=0

in el
Code:

1/3=0.333333...

In the jsp pages we need to do the paging, somethime we need the type of int number, not the fload or double.
How to do the rounding operation?
Code:

<fmt:formatNumber value="${showThisMuch-(showThisMuch%20)}" pattern="00000.#" />
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值