如何在使用jsp GET方法时检查NULL值?

How do I check for a NULL value when using JSPs GET method?

本文关键字:检查 NULL 方法 GET jsp      更新时间:2023-09-26

当提交post方法时,JSP页面将在下一页的字段中显示结果。我怎么能红标记那些字段谁得到空值在第二页?

在forEach循环中可以这样写:

<c:choose>
    <c:when test='${iterator.name eq ''}'>
        <td style='background-color:red;'> <c:outvalue="${iterator.name}"/> </td>
    </c:when>
    <c:otherwise>
        <td> <c:outvalue="${iterator.name}"/> </td>
    </c:otherwise>
</c:choose>

正如你所看到的,当值为null时,你可以将该单元格的背景色设置为红色,当它返回一些值时,你可以像以前那样显示它