Jsp动态生成表格

Posted 熊猫儿

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Jsp动态生成表格相关的知识,希望对你有一定的参考价值。

输入行列:

<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动态生成表格的主要内容,如果未能解决你的问题,请参考以下文章