美文网首页
jsp判断List是否为空

jsp判断List是否为空

作者: 来宝 | 来源:发表于2017-10-12 17:31 被阅读54次

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>

相关文章

网友评论

      本文标题: jsp判断List是否为空

      本文链接:https://www.haomeiwen.com/subject/xpeoyxtx.html