jsp字段判空

时间:2023-03-09 21:56:00
jsp字段判空
是对象吧String
jsp的写法
<% if(str == null) { %>
str is null
<% } else { %>
str not null
<% } %> jstl:<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
使用时要把jstl.jar,standard.jar包拷过来
<c:choose>
<c:when test="${empty str}">
<p>str is null</p>
</c:when>
<c:otherwise>
<p>str not null</p>
</c:otherwise>
</c:choose>
你在页面上可以用C标签.
然后加EL表达式判断.
<c:if test="${empty str}">
str为空
</c:if> <c:if test="${not empty str}">
str不为空
</c:if>