jsp 的 for循环

jsp 的 for循环
jsp中同样可以使用for语句来循环输出内容。for与if一块使用会使得程序流程更加灵活。
达到一些我们想要的效果例如:
<%@ page language="java" contentType="text/html;" charset=utf-8"%>
<html>
<head><title>jsp Scriptlets</title>
<link rel='stylesheet' type='text/css' href='css/style.csss'>
</head>
<body>
<br/>
<%
   Object[] [] leters={
                 {true. "共享您注册的信息已经生效","e_360364641.qq.com","helloweenvsfei@
fmai.com","2012-8-8"},
                  {true,"Java EE 5.0 release!!","admin@sun.com","helloweenvsfei@gmail.com",
"2007-6-24"},
                  {false,"l来信已经收到,下周开始工作","foo@bar.com","helloweenvsfei@gmail
 .com","2007-5-25"},
                   {fale,"您的信箱有留言","360364641@qq.com","helloweenvsfei@gmail.com"
,"2007-3-25"},
};
String[] colors={"#DDDDDD","#AAAAAA",};
%>
     <table horder=0 cellspacing=1 cellpadding=2 width=700 align=center>
         <tr style="background: url(images/vertical_line.gif);">
               <td align="ceter" style="line-height:22px;">&nbsp;</td>
               <td align="ceter"style="ine-height:22px">标题&nbsp;</td>
               <td align="ceter"style="line-height:22px;">发件人&nbsp</td>
               <td align="ceter"style="line-height:22px;">收件人&nbsp</td>
  <td align="ceter"style="line-height:22px;">时间&nbsp</td>
      </tr>
<%
for(int i=0;i<letters.length;ii++){
Object[] letter=letters[i];
%>
          <tr style='background:<%=colors[i%2]%>'>
               <td   align="center">
                   <%
                         if(lttter[0]==Boolean.TRUE){
                  %>
                          <img src="images/mail.gif"/>
                       <%
                            }
                                       else{
                                                  out.println("&nbsp;");
                          }
                         %>
                      </td>
                      <td><a href="#"><%=letter[1]%></a></td>
                      <td><%=letter[2]%></td>
                     <td><%=letter[3]%></td>
                      <td aling="cenetr"><%=letter[4]%></td>
                    </tr>
<%
}
%>
    </table>
</body>
</html>
在该程序中for循环内部使用if语句判断是否为新邮件,如果是新邮件,则邮件状态列显示邮件图标,否则
显示一个空格字符

 

转载于:https://www.cnblogs.com/a464566082/archive/2013/02/18/2916335.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值