EL表达式 获取list长度/不用循环,EL在List中直接获取第一项的内容/EL获取Map的键,Map的值

来源:互联网 发布:淘宝卖家可以开直播吗 编辑:程序博客网 时间:2024/05/21 18:44
转载至:http://www.cnblogs.com/sxdcgaq8080/p/6434682.html
1.EL表达式 获取list长度

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

 

<c:if test="${fn:length(list名字)>1}">

  中间该干嘛干嘛

</c:if>

 

2.不用循环,EL在List中直接获取第一项的内容

${list[0].属性}

 

3.EL获取Map的键,Map的值

<c:forEach items="${map名字}" var="k">
  <option value="${k.key }">${k.value}</option>
</c:forEach>

 

这样分别获取键和值。