jsp页面输出N行3列的表格,完整的代码贴

解决方案 »

  1.   


        <table border="1">
          <%
            for (int n = 1; n <= 100; n++)
            {
          %>
          <tr>
            <%
              for (int w = 1; w <= 5; w++)
              {
            %>
            <td width="85">&nbsp;</td>
            <% //
              }
            %>
          </tr>
          <% //
            }
          %>
        </table>
      

  2.   

    思路,单纯的用jsp中嵌套java代码,还是用el表达式?
    下面是一种用el表达是些的
    <table border="1">
    <tr>
    <c:forEach begin="0" end="n" var="ss" varStatus="status">
    <td>${ss }</td>

    <c:if test="${(status.index+1)%3 eq 0}">
    </tr>
    <tr>
    </c:if>
    </c:forEach>
    </tr>
    </table>
      

  3.   


    <%@ page contentType="text/html; charset=gb2312" language="java"  %><html>
    <head>
    <title>输出N行3列</title>
    </head>
    <body>
    <center>
    <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#408080"  >
    <% 
        int n=80;/*N 这里就是你要控制的N,自己给值%/
        
        for(int i=1;i<=n;i++)
       {
        %>
         <tr>
           <%
              for(int j=1;j<=3;j++);
              {
                %>
                 <td>&nbsp;</td>
                <%
               }
             %>
         </tr><%
       }
        %>
    <table>
    </center>
    </body>
    </html>