首页 > Web开发 > 详细

Jsp动态生成表格

时间:2016-11-13 16:48:54      阅读:335      评论:0      收藏:0      [点我收藏+]

输入行列:

<body>

<form action="Train2ResultJsp.jsp">
row:<input type="text" name="row"><br>
column:<input type="text" name="column"><br>
<input type="submit" value="submit">&nbsp;&nbsp;
<input type="reset" value="reset">
</form>
</body>

生成表格:

<body>
<%
int row=0;
int col=0;
try{
row=Integer.parseInt(request.getParameter("row"));
col=Integer.parseInt(request.getParameter("column"));
}catch(Exception ex){
out.println("please input integer!");
return;
}
int val=1;
%>
<table border="1">

<%for(int i=0;i<row;i++){ %>
<tr>
<%for(int j=0;j<col;j++){%>

<td>
<%=val++ %>
</td>

<%} %>
</tr>
<%} %>

</table>
</body>

Jsp动态生成表格

原文:http://www.cnblogs.com/qcxdoit/p/6058748.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!