如果标记在jstl中检查为空

时间:2012-09-05 14:45:49

标签: jstl

我的代码迭代列表并显示行

<c:if test="${not empty ftp}">
    <c:forEach var="event" items="${ftp}">
                <tr><td><input type="text" name="hostName" id="hostName" value="${event.hostName}"size="30" maxlength="200"/></td>
                <td><input type="text" name="directory" id="directory" value="${event.directory}" size="30" maxlength="200"/></td>
                <td><input type="text" name="userName" id="userName" value="${event.userName}" size="20" maxlength="20"/></td>
                <td><input type="text" name="password" id="password" value="${event.password}" size="20" maxlength="20" onblur="checkEnableButton();"/></td>
                <td><input type="button" id="delete" onclick="if(confirm( 'Do you want to delete')) deleteRow(this);" value="-" /></td></tr>
            </c:forEach>
</c:if>

这很好..但是,如果我的列表为空,我需要显示一个空白行..?如果我想从JSP页面删除并添加dynamicaaly行,我该怎么办??

1 个答案:

答案 0 :(得分:0)

您当前对<c:if test="${not empty ftp}">...</c:if>的使用可以被移除,因为forEach循环也会执行相同的检查,如果它确实为空,则跳过任何处理。

如果显示空行,则可以执行以下操作:

<c:if test="${empty ftp}">
    ...display empty table row here...
</c:if>

如果你想动态地做事,你需要开发一些JavaScript。 JSTL在服务器上完成,但JavaScript允许您进行动态客户端处理。

相关问题