一、在EL表達中使用empty,
<c:if test="${not empty logisticsDetailList}">
<c:forEach items="${logisticsDetailList}" var="list">
<tr>
<td align="center" >
${list.time}
</td>
<td align="left">
<span style="display:block;" title="${list.contenxt}">${list.contenxt}</span>
</td>
</tr>
</c:forEach>
</c:if>
<c:if test="${empty logisticsDetailList}">
<tr>
<td align="center" colspan="2">
<span style="color: #003688;font-weight:bold;font-size:16px">暫無物流資訊!</span>
</td>
</tr>
</c:if>
<c:if test="${! empty key}">${key}</c:if> 或者<c:if test="${not empty key}"> <c:if test="${empty key}">所有</c:if> 當key不為空白時輸出key的值。當key為空白時,輸出“所有” 規則: 1若key為null時,返回true 2若key為空白String時,返回true 3若key為空白Array時,返回true 4若key為空白Map時,返回true 5若key為空白Collection時,返回true 6否則,返回false
二、struts2標籤對null和Null 字元串判斷
<s:if test="#request.logisticsDetailList!=null&&#request.logisticsDetailList.size>0">
也可以這樣使用:<s:if test="#request.logisticsDetailList!=null&&!#request.logisticsDetailList.isEmpty()">
<c:forEach items="${logisticsDetailList}" var="list">
<tr>
<td align="center" >
${list.time}
</td>
<td align="left">
<span style="display:block;" title="${list.contenxt}">${list.contenxt}</span>
</td>
</tr>
</c:forEach>
</s:if>
<s:if test="#request.logisticsDetailList!=null&&#request.logisticsDetailList.size>0">如果是字串可以 <s:if test="#request.username!=null&&#request.username!=''">單引號
這樣也可以使用取到相同效果。