logic:iterate 标签,如何实现隔行显示不同的颜色

nftdxnftdx 2009-01-12 03:22:07
下面是logic:iterate的具体内容,kensakuBeans为传过来的一个链表,如何实现让显示出来的数据隔行的颜色不一样,比如说第一行无背景色,第二行红色,第三行我背景色,第四行又是红色......
<logic:iterate id="kensaku" name="kensakuBeans">
<tr>
<td class="settle1"><bean:write name="kensaku" property="tesokuNO"/></td>
<td class="settle1" width="600"><bean:write name="kensaku" property="tesokuName"/></td>
<td align="center" class="settle1" colspan="3"><a href="detail.do?tesokuNO=<bean:write name="kensaku" property="tesokuNO"/>">一覧</a> </td>

</tr>
</logic:iterate>
...全文
616 25 打赏 收藏 转发到动态 举报
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
psbye 2011-03-16
  • 打赏
  • 举报
回复
qiujie
mantoupaozi 2009-12-09
  • 打赏
  • 举报
回复
嘿嘿。。好用的东西
jjtking 2009-01-14
  • 打赏
  • 举报
回复
页面上加个变量,记住是哪行,想要多复杂的颜色规则都行。
qinmingjun718 2009-01-14
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zhj92lxs 的回复:]
<logic:iterate id="list" name="list" indexId="index">
<tr bgcolor=" <%=(index.intValue() % 2 == 0) ? "red" : "blue"%>">
<td>
aaaaaaaaaa
</td>
</tr>
</logic:iterate>
[/Quote]
肯定可以
fanyuanwaifdl 2009-01-14
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 yukang_ky 的回复:]
引用 1 楼 zhj92lxs 的回复:
<logic:iterate id="list" name="list" indexId="index">
<tr bgcolor=" <%=(index.intValue() % 2 == 0) ? "red" : "blue"%>">
<td>
aaaaaaaaaa
</td>
</tr>
</logic:iterate>


正解。
[/Quote]··
Ami121 2009-01-14
  • 打赏
  • 举报
回复

<logic:iterate id="list" name="list" indexId="index">
<c:if test="${index%2 ==0}"
<tr bgcolor="red">
<td>
aaaaaaaaaa
</td>
</tr>
</c:if>
<c:if test="${index%2 !=0}"
<tr bgcolor=" green">
<td>
bbbbbbbbbb
</td>
</tr>
</c:if>
</logic:iterate>

jsf_jsp 2009-01-13
  • 打赏
  • 举报
回复
利用odd 和even奇偶行,有这两个属性
pxcong007 2009-01-13
  • 打赏
  • 举报
回复
思想就是用/2来判断。

steryzone 2009-01-13
  • 打赏
  • 举报
回复
首先判断(用%2得到的是1、还是0)
然后可以用标签
<logic:iterate id="kensaku" name="kensakuBeans">
<logic:equal name="kensaku" property="rowColor" value="1"><tr bgcolor="#FF0000"></logic:equal>
<logic:equal name="kensaku" property="rowColor" value="0"><tr bgcolor="#FFFFFF"></logic:equal>
.
.
.
.

</logic:iterate>
glglglglglgllll 2009-01-12
  • 打赏
  • 举报
回复
主要是去判断
wuxiaopeng520 2009-01-12
  • 打赏
  • 举报
回复
<logic:iterate id="kensaku" name="kensakuBeans">

<tr bgcolor=" <%=(index.intValue() % 2 == 0) ? "red" : "blue"%>">
<td class="settle1"> <bean:write name="kensaku" property="tesokuNO"/> </td>
<td class="settle1" width="600"> <bean:write name="kensaku" property="tesokuName"/> </td>
<td align="center" class="settle1" colspan="3"> <a href="detail.do?tesokuNO= <bean:write name="kensaku" property="tesokuNO"/>">一覧 </a> </td>

</tr>

</logic:iterate>
rainsilence 2009-01-12
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 SmallFishZhang 的回复:]
<style type="text/css">
#main tr {
background-color:expression((this.sectionRowIndex%2==0)?"#E1F1F1":"#F0F0F0")
}
</style>
[/Quote]
想法很好,但是如果遇到禁用javascript得浏览器怎么办?
flylovejings 2009-01-12
  • 打赏
  • 举报
回复
呵呵

一个CSS搞定他!

楼上有人顶出来了!

collect it!
Jacky_Zhu_1983 2009-01-12
  • 打赏
  • 举报
回复
<style type="text/css">
.main {
color:expression((this.sectionRowIndex%2==0)?"red":"green")
}
</style>
<body>
<table >
<logic:iterate id="kensaku" name="kensakuBeans">
<tr class="main">
<td class="settle1"> <bean:write name="kensaku" property="tesokuNO"/> </td>
<td class="settle1" width="600"> <bean:write name="kensaku" property="tesokuName"/> </td>
<td align="center" class="settle1" colspan="3"> <a href="detail.do?tesokuNO= <bean:write name="kensaku" property="tesokuNO"/>">一覧 </a> </td>

</tr>
</logic:iterate>
</table>
</body>
yami251139 2009-01-12
  • 打赏
  • 举报
回复
我倒。。。
用css不可以么,为什么要浪费性能在这中上面
如果有100W条数据,就为了这么点小事,就要浪费多少cpu啊~~~~
wj_18 2009-01-12
  • 打赏
  • 举报
回复
判断数据是不是2的倍数
yukang_ky 2009-01-12
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zhj92lxs 的回复:]
<logic:iterate id="list" name="list" indexId="index">
<tr bgcolor=" <%=(index.intValue() % 2 == 0) ? "red" : "blue"%>">
<td>
aaaaaaaaaa
</td>
</tr>
</logic:iterate>
[/Quote]

正解。
rijiuyou01 2009-01-12
  • 打赏
  • 举报
回复
mark
SmallFishZhang 2009-01-12
  • 打赏
  • 举报
回复
<style type="text/css">
#main tr {
background-color:expression((this.sectionRowIndex%2==0)?"#E1F1F1":"#F0F0F0")
}
</style>
<body>
<table class="main">

<logic:iterate id="kensaku" name="kensakuBeans">
<tr>
<td class="settle1"> <bean:write name="kensaku" property="tesokuNO"/> </td>
<td class="settle1" width="600"> <bean:write name="kensaku" property="tesokuName"/> </td>
<td align="center" class="settle1" colspan="3"> <a href="detail.do?tesokuNO= <bean:write name="kensaku" property="tesokuNO"/>">一覧 </a> </td>

</tr>

</logic:iterate>
</table>
</body>
longman337 2009-01-12
  • 打赏
  • 举报
回复
循环判断奇偶行数
加载更多回复(4)

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧