如何在JSP页面使用JSTL标签获取List的元素个数

来源:互联网 发布:ios10.2.1网络验证失败 编辑:程序博客网 时间:2024/06/17 19:30

1. 工程中要有:jstl.jar 和 standard.jar 这两个jar包。

2. 页面中导入JSTL core和JSTL functions标签库:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

3 . 例如,你要测试一个List变量elements中的元素个数是否为0,就可以像下边这样:

<c:when test="${fn:length(m_messages.elements)>0}">

......

</c:when>

<c:otherwise>
.....

</c:otherwise>

原创粉丝点击