【问题标题】:Unexpected JSTL EL results意外的 JSTL EL 结果
【发布时间】:2017-07-01 08:42:10
【问题描述】:

我从一个循环中得到了意想不到的结果,该循环显示了我来自 MySQL 数据库的新闻帖子。这是EL代码:

<table class="newsbox" width="400" border="0">
<tbody>
<tr>
<td class="date">Date/time</td>
<td class="username">Posted By</td>
<td class="title">Title</td>
<td class="content">Action</td>
</tr>
<c:forEach items="${nwg.getNews()}" varStatus="loop">
<tr>
<td class="date"><c:out value="${nwg.getNews().get('date')[loop.index]}"/></td>
<td class="username"><c:out value="${nwg.getNews().get('username')[loop.index]}" /></td>
<td class="title"><c:out value="${nwg.getNews().get('title')[loop.index]}" /></td>
<td class="content"><a href="Servlet/Admin/News?action=del&id=${nwg.getNews().get('id')[loop.index]}">Delete</a> / Edit</td>
</tr>
</c:forEach>
</tbody>
</table>

问题是无论数据库中有多少新闻帖子,它都会输出另外 4 个删除/编辑链接。就像说如果我有 1 篇新闻帖子,它将显示新闻帖子删除/编辑链接以及另外 4 个没有 id= 值的空白删除/编辑链接。我认为问题出在 forEach 循环中。非常感谢您的帮助!

【问题讨论】:

    标签: jsp foreach jstl el


    【解决方案1】:

    对不起,没关系,我已经修好了。我改变了 forEach 循环的工作方式,现在它的行为正常。还是干杯!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-15
      • 2012-04-02
      • 2019-05-14
      • 2017-07-11
      • 2011-04-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多