六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 70|回复: 0

JSTL 比教时间

[复制链接]

升级  72%

8

主题

8

主题

8

主题

童生

Rank: 1

积分
36
 楼主| 发表于 2013-2-6 08:44:45 | 显示全部楼层 |阅读模式
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.#" />
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表