首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

iterator 循环 tr td 怎么循环成3行4列有代码

2012-03-11 
iterator 循环 tr td 如何循环成3行4列有代码s:iterator valuelist idcc statussttablewidth

iterator 循环 tr td 如何循环成3行4列有代码
<s:iterator value="list" id="cc" status="st"> 
  <table width="143" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
  <td align="center" style="padding-top:10px;">
   
  <s:if test="#cc=='by'">
  <div style="float:left;padding:2px;margin-right:5px;margin-left:10px;margin-bottom:10px;">
<table width="143" height="125" border="0" cellpadding="0" cellspacing="0" background="./website_img/shop/shopIMG2.png">
<tr>
<td align="center" style="padding-top:10px;"><img src="images/star/by.jpg" width="64" height="65"/></td>
</tr>
<tr>
<td align="center"><div id="div" style="font-weight:bold;"> <a style="cursor:default" >白羊座</a></div></td>
</tr>
</table>
</div>
  </s:if>
  <s:elseif test="#cc=='jn'">
  <div style="float:left; padding:2px;margin-right:5px;margin-left:10px;margin-bottom:10px;">
<table width="143" height="125" border="0" cellpadding="0" cellspacing="0" background="./website_img/shop/shopIMG2.png">
<tr>
<td align="center" style="padding-top:10px;"><img src="images/star/jn.jpg" width="64" height="65"/></td>
</tr>
<tr>
<td align="center"><div id="div" style="font-weight:bold;"> <a style="cursor:default" >金牛座</a></div></td>
</tr>
</table>
</div>
</s:elseif>
  <s:elseif test="#cc=='szz'">
  <div style="float:left; padding:2px;margin-right:5px;margin-left:10px;margin-bottom:10px;">
<table width="143" height="125" border="0" cellpadding="0" cellspacing="0" background="./website_img/shop/shopIMG2.png">
<tr>
<td align="center" style="padding-top:10px;"><img src="images/star/szz.jpg" width="64" height="65"/></td>
</tr>
<tr>
<td align="center"><div id="div" style="font-weight:bold;"> <a style="cursor:default" >双子座</a></div></td>
</tr>
</table>
</div>
</s:elseif>
  <s:elseif test="#cc=='jx'">
  <div style="float:left; padding:2px;margin-right:5px;margin-left:10px;margin-bottom:10px;">
<table width="143" height="125" border="0" cellpadding="0" cellspacing="0" background="./website_img/shop/shopIMG2.png">


<tr>
<td align="center" style="padding-top:10px;"><img src="images/star/jx.jpg" width="64" height="65"/></td>
</tr>
<tr>
<td align="center"><div id="div" style="font-weight:bold;"> <a style="cursor:default" >巨蟹座</a></div></td>
</tr>
</table>
</div>
</s:elseif>
  <s:elseif test="#cc=='sz'">
  <div style="float:left; padding:2px;margin-right:5px;margin-left:10px;margin-bottom:10px;">
<table width="143" height="125" border="0" cellpadding="0" cellspacing="0" background="./website_img/shop/shopIMG2.png">
<tr>
<td align="center" style="padding-top:10px;"><img src="images/star/sz.jpg" width="64" height="65"/></td>
</tr>
<tr>
<td align="center"><div id="div" style="font-weight:bold;"> <a style="cursor:default" >狮子座</a></div></td>
</tr>
</table>
</div>
</s:elseif>
  <s:elseif test="#cc=='cn'">
  <div style="float:left; padding:2px;margin-right:5px;margin-left:10px;margin-bottom:10px;">
<table width="143" height="125" border="0" cellpadding="0" cellspacing="0" background="./website_img/shop/shopIMG2.png">
<tr>
<td align="center" style="padding-top:10px;"><img src="images/star/cn.jpg" width="64" height="65"/></td>
</tr>
<tr>
<td align="center"><div id="div" style="font-weight:bold;"> <a style="cursor:default" >处女座</a></div></td>
</tr>
</table>
</div>
</s:elseif>
  <s:elseif test="#cc=='tp'">
  <div style="float:left; padding:2px;margin-right:5px;margin-left:10px;margin-bottom:10px;">
<table width="143" height="125" border="0" cellpadding="0" cellspacing="0" background="./website_img/shop/shopIMG2.png">
<tr>
<td align="center" style="padding-top:10px;"><img src="images/star/tp.jpg" width="64" height="65"/></td>
</tr>
<tr>
<td align="center"><div id="div" style="font-weight:bold;"> <a style="cursor:default" >天秤座</a></div></td>
</tr>
</table>
</div>
</s:elseif>
  <s:elseif test="#cc=='tx'">
  <div style="float:left; padding:2px;margin-right:5px;margin-left:10px;margin-bottom:10px;">
<table width="143" height="125" border="0" cellpadding="0" cellspacing="0" background="./website_img/shop/shopIMG2.png">


<tr>
<td align="center" style="padding-top:10px;"><img src="images/star/tx.jpg" width="64" height="65"/></td>
</tr>
<tr>
<td align="center"><div id="div" style="font-weight:bold;"> <a style="cursor:default" >天蝎座</a></div></td>
</tr>
</table>
</div>
</s:elseif>
  <s:elseif test="#cc=='ss'">
  <div style="float:left;padding:2px;margin-right:5px;margin-left:10px;margin-bottom:10px;">
<table width="143" height="125" border="0" cellpadding="0" cellspacing="0" background="./website_img/shop/shopIMG2.png">
<tr>
<td align="center" style="padding-top:10px;"><img src="images/star/ss.jpg" width="64" height="65"/></td>
</tr>
<tr>
<td align="center"><div id="div" style="font-weight:bold;"> <a style="cursor:default" >射手座</a></div></td>
</tr>
</table>
</div>
</s:elseif>
  <s:elseif test="#cc=='mx'">
  <div style="float:left; padding:2px;margin-right:5px;margin-left:10px;margin-bottom:10px;">
<table width="143" height="125" border="0" cellpadding="0" cellspacing="0" background="./website_img/shop/shopIMG2.png">
<tr>
<td align="center" style="padding-top:10px;"><img src="images/star/mx.jpg" width="64" height="65"/></td>
</tr>
<tr>
<td align="center"><div id="div" style="font-weight:bold;"> <a style="cursor:default" >摩羯座</a></div></td>
</tr>
</table>
</div>
</s:elseif>
  <s:elseif test="#cc=='sp'">
  <div style="float:left; padding:2px;margin-right:5px;margin-left:10px;margin-bottom:10px;">
<table width="143" height="125" border="0" cellpadding="0" cellspacing="0" background="./website_img/shop/shopIMG2.png">
<tr>
<td align="center" style="padding-top:10px;"><img src="images/star/sp.jpg" width="64" height="65"/></td>
</tr>
<tr>
<td align="center"><div id="div" style="font-weight:bold;"> <a style="cursor:default" >水平座</a></div></td>
</tr>
</table>
</div>
</s:elseif>
  <s:elseif test="#cc=='sy'">
  <div style="float:left; padding:2px;margin-right:5px;margin-left:10px;margin-bottom:10px;">
<table width="143" height="125" border="0" cellpadding="0" cellspacing="0" background="./website_img/shop/shopIMG2.png">


<tr>
<td align="center" style="padding-top:10px;"><img src="images/star/sy.jpg" width="64" height="65"/></td>
</tr>
<tr>
<td align="center"><div id="div" style="font-weight:bold;"> <a style="cursor:default" >双鱼座</a></div></td>
</tr>
</table>
</div>
</s:elseif>
  </td>
  </tr>
  </table>
  </s:iterator>

--------------------------------------------------------------------

如何循环成3行4列 在线求解啊

[解决办法]
循环出多少行是根据你的数据来的吧。
[解决办法]
你中间做个判断啊,到了4个就换一行啊。
用一个for循环中间用一个if判断就可以搞定了。
[解决办法]
就 这样 了 , 你试试 

Java code
    <table width="143" border="0" cellspacing="0" cellpadding="0" align="center">        <tr>            <s:iterator value="list" id="cc" status="st">                    <td align="center" style="padding-top: 10px;">                         …………………………                         …………………………                    </td>        <s:if test="#s.modules(4)==0 && !#status.first && !#status.last">            </tr>            <tr>        </s:if>            </s:iterator>        </tr>    </table>
[解决办法]
探讨

是啊,那得怎么循环啊引用:
循环出多少行是根据你的数据来的吧。

[解决办法]
探讨
是啊,那得怎么循环啊

引用:
循环出多少行是根据你的数据来的吧。

[解决办法]
探讨

不好用呢引用:
就 这样 了 , 你试试

Java code


<table width="143" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<s:iterator value="list" id="cc" status="st">
……

热点排行