迭代 JSP 指定次数
Iterate in JSP a specified number of times
我需要JSP创建一个table,一个header,然后根据索引的输入形式创建单元格。所以它会如下图所示。每个新行都是从一个循环中计算出来的,其中用户输入的限制是它将下降的行数。
<column1header><column2header>
<1> <1 computed>
<2> <2 computed>
<...> <............>
<limit> <limit computed>
你可以这样做:
<table>
<!-- here should go some titles... -->
<tr>
<th>column1header</th>
<th>column2header</th>
</tr>
<c:forEach var="i" begin="0" end="${user.limit}">
<tr>
<td>${i}</td>
<td>${i} computed</td>
</tr>
</c:forEach>
</table>
参考以下链接:
How to create table dynamically using count and JSTL ForEach
Dynamic database table display using Jstl
可能是你没有在web.xml中正确设置servlet,或者索引形式的动作路径是错误的,因为它可能应该在前面包含“/”。
遇到你这样的问题,我总是在我的代码中插入一个println代码,打印代码可以帮助定位问题区域。
我需要JSP创建一个table,一个header,然后根据索引的输入形式创建单元格。所以它会如下图所示。每个新行都是从一个循环中计算出来的,其中用户输入的限制是它将下降的行数。
<column1header><column2header>
<1> <1 computed>
<2> <2 computed>
<...> <............>
<limit> <limit computed>
你可以这样做:
<table>
<!-- here should go some titles... -->
<tr>
<th>column1header</th>
<th>column2header</th>
</tr>
<c:forEach var="i" begin="0" end="${user.limit}">
<tr>
<td>${i}</td>
<td>${i} computed</td>
</tr>
</c:forEach>
</table>
参考以下链接:
How to create table dynamically using count and JSTL ForEach
Dynamic database table display using Jstl
可能是你没有在web.xml中正确设置servlet,或者索引形式的动作路径是错误的,因为它可能应该在前面包含“/”。
遇到你这样的问题,我总是在我的代码中插入一个println代码,打印代码可以帮助定位问题区域。