JSP页面开头要包含
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
从controller拿到List以后,jsp页面判断并展示:
<c:if test="${userList!=null && fn:length(userList) > 0}">
<label>XXX</label>
<c:forEach var="user" items="${userList}">
<li>${user}</li>
</c:forEach>
</c:if>
原文:https://blog.csdn.net/just_lion/article/details/17239023
判断一个对象是否为空? js
其实开发过程中常常会遇到判断对象和数组是否为空?下面介绍3种判断对象是否为空
1. 最常见的思路,for...in...遍历属性,为真则为“非空数组”;否则为“空数组”
function judgeObj(obj){ for(var attr in obj){ return console.log('非空对象') } return console.log('空对象') }
2.通过JSON自带的.stringify方法判断(上传数据常用)
if(JSON.Stringify(c)=='{}'){ console.log(''空) }
3.当然就是ES6的语法啦,Object.key();
if(Object.key(obj).length==0){ console.log('空对象') }else{ console.log('非空对象') }
el表达式判断 集合 或对象是否为空
引入 <%@ taglib uri="http://java.sun.com/jstl/c" prefix="c"%>
<c:if test="${ empty XX }>判断是否为空</c:if>
<c:if test="${ !empty xx }>判断不为空</c:if>