zoukankan      html  css  js  c++  java
  • jsp输出显示表格

    1.定义输出显示表格行数和列数表单叶

     1 <html>
     2    <head>
     3    <title>我的</title>
     4    </head>
     5    <body>
     6    <form action="print_table.jsp" method="post">
     7    <table border="1"width="100%">//border是显示不显示边框的问题,0代表不显示出来,1代表显示出来  100%是网站采用百分比制作后,可适应浏览者机器的任意屏幕分辨率尺寸,
     8  <tr>
     9    <td>输入要显示的表格行数</td>
    10    <td><input type="text" name="row"></td>
    11  </tr>
    12       <tr>
    13       <td>输入要显示表格的列数</td>
    14       <td><input type="text" name="col"></td>
    15      </tr>
    16  <tr>
    17 <td colspan="2">                 //而colspan是这个列跨度为两列的位置,说白点,就是取消了这两个列中间的横线,变成了一个列
    18   <input type="submit" value="显示">
    19   <input type="reset" value="重置">
    20 </td>
    21    </tr>
    22  
    23        </table>
    24      </form>
    25    </body>
    26 </html>

    2.处理表格显示

     1 <html>
     2   <head><title>表格</title></head>
     3   <body>
     4   <table border="1"width="100%">
     5   <%
     6   int rows=0;
     7   int cols=0;
     8      try{
     9          rows=Integer.parseInt(request.getParameter("row"));   //Integer.parseInt转化成整形否则抛出异常,request.getParameter接受来自htm表单的数据,括号里指name
    10          cols=Integer.parseInt(request.getParameter("col"));
    11      }catch(Exception e){}
    12     for(int x=0;x<rows;x++){
    13   %>
    14   <tr>
    15   <%
    16          
    17        for(int y=0;y<cols;y++){
    18   %>
    19   <td><%=(x*y)%></td>
    20   <%
    21        }
    22   %>
    23   </tr>
    24   <%
    25      }
    26   %>
    27   </table>
    28     </body>
    29   </html>
  • 相关阅读:
    例6-5
    例6-3
    例6-2
    例6-1
    例5-9
    python3
    python3
    python3
    python3
    python3
  • 原文地址:https://www.cnblogs.com/anuo007/p/3556941.html
Copyright © 2011-2022 走看看