<tr>
        <td height="25" align="center" valign="middle" class="STYLE6 STYLE8">宽和高</td>
        <c:forEach var="item" items="${scrnSizeList}" begin="0" end="4"><!--个数是不确定的所以不能用begin end-->
         <td height="25" align="center" valign="middle" class="STYLE6 STYLE8">
                ${item.width}×${item.height}
           </td>
        </c:forEach>
</tr>这个forEach现在是放在一行里面的!
我想做的是,4列之后换一行重起一个<tr>有啥办法能解决么?

解决方案 »

  1.   

    欢迎回访http://blog.csdn.net/y18173453131
      

  2.   

    提示:
    <c:forEach varStatus="status" var="item" items="${scrnSizeList}">
            <c:if test="${(status.index+1) mod 4 == 0}">
                             
                 
            </c:if>
            <c:if test="${(status.index+1) mod 4 != 0}">
                             
                 
            </c:if>
    </c:forEach>
    这样应该可以的!lz再想想
      

  3.   


    没看明白!没用过varStatus 和 mod
      

  4.   

    就是这样,${(status.index+1) mod 4 == 0}时候,添加tr
      

  5.   


    varStatus是循环的信息,里面的index表示现在是第几项,
    mod是模,mod 4表示除以4得到的余数
      

  6.   

     <table width="500" border="0" cellspacing="0" cellpadding="0">
    <tr>
            <td height="25" align="center" valign="middle" class="STYLE6 STYLE8">宽和高</td>
            <c:forEach var="item" items="${scrnSizeList}" begin="0" end="4"><!--个数是不确定的所以不能用begin end-->
                <td height="25" align="center" valign="middle" class="STYLE6 STYLE8">
                       ${item.width}×${item.height}
               </td>
            </c:forEach>
    </tr>
    </table>疯了,疯了!才发现我的table是这样的!
    forEach在<tr>里面!!!!
      

  7.   


    <tr>
            <td height="25" align="center" valign="middle" class="STYLE6 STYLE8">大小</td>
            <c:forEach var="item" items="${scrnSizeList}" varStatus="status">
           
               <c:if test="${(status.index+1) mod 4 !=0}">
                <td height="25" align="left" valign="middle" class="STYLE6 STYLE8">
                  ${item.width}×${item.height}
                </td>
               </c:if>
               <c:if test="${(status.index+1) mod 4==0}">
             <tr>
             <td>
             <td height="25" align="left" valign="middle" class="STYLE6 STYLE8">
                 ${item.width}×${item.height}
                </td>
                 </c:if>
            </c:forEach>
          </tr>这样写是OK了!差不多!但是第一行只显示3个<td>其它都是4个<td>240×320   128×128   480×640  
    64×64     120×80    450×600   10×10  
    20×20     30×30     40×40   50×50  
    60×60  
    酱紫显示的!
      

  8.   

    <table width="500" border="0" cellspacing="0" cellpadding="0">
    <tr>
            <td height="25" align="center" valign="middle" class="STYLE6 STYLE8">宽和高</td>
            <c:forEach var="item" items="${scrnSizeList}" begin="0" end="4"><!--个数是不确定的所以不能用begin end-->
                <td height="25" align="center" valign="middle" class="STYLE6 STYLE8">
                       ${item.width}×${item.height}
               </td>
               <c:if test="${(status.index+1) mod 4 == 0}"> 
                 </tr><tr>
                     <td>第一列(宽和高)</td>           </c:if>
            </c:forEach>
    </tr>
    </table>
    加上上面的应该可以了
      

  9.   


    谢谢!
    但是是${(status.index+1) mod 4 !=0}的情况下才会少个<td>我再想想!在forEach外面加个<td>就是一样多的了,但是没数据显示!
      

  10.   

    <tr>
            <td height="25" align="center" valign="middle" class="STYLE6 STYLE8">大小</td>
            <c:forEach var="item" items="${scrnSizeList}" varStatus="status">
           
               <c:if test="${(status.index+1) mod 4 !=1}">
                       <td height="25" align="left" valign="middle" class="STYLE6 STYLE8">
                        ${item.width}×${item.height}
                       </td>
               </c:if>
               <c:if test="${(status.index+1) mod 4==1}">
                </tr>
                <tr>
                <td height="25" align="left" valign="middle" class="STYLE6 STYLE8">
                    ${item.width}×${item.height}
                </td>
                 </c:if>
            </c:forEach>
          </tr>