Jsp 如何使用count和JSTL ForEach动态创建表

Jsp 如何使用count和JSTL ForEach动态创建表,jsp,foreach,jstl,Jsp,Foreach,Jstl,我想创建一个动态表,当它提供了要在上一页中输入的图书数量时,接受图书属性。 但我什么也没有得到 这是我的代码: <table> <c:forEach begin="1" end= "${ no }" step="1" varStatus="loopCounter"> <tr> <td> <input type='text' name="isbn" placeholder="ISBN"> </td> <td> &l

我想创建一个动态表,当它提供了要在上一页中输入的图书数量时,接受图书属性。 但我什么也没有得到

这是我的代码:

<table>
<c:forEach begin="1" end= "${ no }" step="1" varStatus="loopCounter">
<tr>
<td>
<input type='text' name="isbn" placeholder="ISBN">
</td>
<td>
<input type="text" name="Title" placeholder="Title">
</td>
<td>
<input type="text" name="Authors" placeholder="Author">
</td>
<td>
<input type="text" name="Version" placeholder="Version">
</td>
</tr>
</c:forEach>
</table>

${no}是我要输入的图书数。
我是新来的。如果标题不清楚,很抱歉。请帮助。

你没有得到任何东西,因为你没有重复你的书单。此外,在每次迭代中只打印大量的
。您的代码应该如下所示(假设您的图书列表是
lstBooks
,并且已经初始化):

然后您可以使用
${no}
访问它

更多信息:

假设您提供了一份map
List
underEmployees的列表

你手下的员工
员工Id
名字
姓
任命


名字
姓
年龄
${student.firstName}
${student.lastName}
${student.age}

我正在尝试接受输入。这就是为什么我有。实际上,所有的例子都是基于迭代的。是否可以像正常循环一样工作??例如:打印一行10次你想输入你的书的值吗?是的。我想创建这个动态表单,它不接受来自用户的任何书籍。它将输入作为上一页的图书数量。抱歉信息太少。好吧,假设这个
${no}
变量作为一个属性来自上一个请求,您的
应该作为
for循环使用。您可能遇到的问题是
${no}
变量具有
null
0
值。您可以通过在循环之前添加
来进行一个简单的测试。我想我发现了问题所在。我发现${no}不起作用。我试过了{pageScope.no}但没有成功。现在“s”变量对我起作用了。非常感谢你的帮助。只是想用${}作为数字,不用担心。非常感谢您抽出时间。
<table>
    <!-- here should go some titles... -->
    <tr>
        <th>ISBN</th>
        <th>Title</th>
        <th>Authors</th>
        <th>Version</th>
    </tr>
    <c:forEach begin="1" end= "${ no }" step="1" varStatus="loopCounter"
        value="${lstBooks}" var="book">
    <tr>
        <td>
            <c:out value="${book.isbn}" />
        </td>
        <td>
            <c:out value="${book.title}" />
        </td>
        <td>
            <c:out value="${book.authors}" />
        </td>
        <td>
            <c:out value="${book.version}" />
        </td>
    </tr>
    </c:forEach>
</table>
<c:set var="no" value="10" />
<caption>Emplyess Under You</caption>
<tr>
    <th>Employee Id</th>
    <th>First Name</th>
    <th>Last Name</th>
    <th>Designation
</tr>
<c:forEach  var="record"  items="${underEmployees}" > 
    <tr>
        <c:forEach var="entry" items= "${record}">
            <th><c:out value="${entry.value}"></c:out></th>
        </c:forEach>

    </tr>
</c:forEach>
<table>
  <tr>
    <th>First name</th>
    <th>Last Name</th>
    <th>Age</th>
  </tr>
  <c:forEach items="${students }" var="student">
    <tr>
      <td>${student.firstName}</td>
      <td>${student.lastName }</td>
      <td>${student.age }</td>
    </tr>
  </c:forEach>
</table>