打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
jsp jstl c标签 list map

${list[0].username}<br>

${list[1].username}<br>

${list[2].username}<br>

<%List<TestUser> list = (List)request.getAttribute("list"); %><br>

username:<%=list.get(0).getUsername() %><br>

<c:forEach items="${list }" var="person">

c标签username:${person.username }<br>

</c:forEach>


${map.person1.username}<br>

${map["person2"].username }<br>

${map["1"].username }<br>

<c:if>和<c:when>

<c:if>没有<c:else>可以用<c:choose>来取代结构:

<c:choose>

   <c:when test="">    如果

   </c:when>

   <c:otherwise>  否则

   </c:otherwise>

</c:choose>

在同一个 <c:choose> 中,当所有 <c:when> 的条件都没有成立时,则执行 <c:otherwise> 的本体内容。

  语法

  <c:otherwise>

  本体内容

  </c:otherwise>

  属性

  无

  限制

  ·<c:otherwise> 必须在 <c:choose> 和 </c:choose>之间

  ·在同一个 <c:choose> 中时,<c:otherwise> 必须为最后一个标签

  说明

  在同一个 <c:choose> 中,假若所有 <c:when> 的test属性都不为true时,则执行 <c:otherwise> 的本体内容。

  范例

  笔者举一个典型的 <c:choose>、<c:when>和<c:otherwise>范例:

  <c:choose>

  <c:when test="${condition1}">

  condition1为true

  </c:when>

  <c:when test="${ condition2}">

  condition2为true

  </c:when>

  <c:otherwise>

  condition1和condition2都为false

  </c:otherwise>

  </c:choose>

  范例说明:当condition1为true时,会显示“condition1为true”;当condition1为false且condition2为true时,会显示“condition2为true”,如果两者都为false,则会显示“condition1和condition2都为false”。

  注意

  假若condition1和condition2两者都为true时,此时只会显示"condition1为true",这是因为在同一个<c:choose>下,当有好几个<c:when>都符合条件时,只能有一个<c:when>成立。


本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
jstl(jsp标准标签库)介绍
标签/c:choose/、/c:when/和/c:otherwise/
OGNL和EL表达式对比 Struts2标签和JSTL对比
入门教程:JSP标准模板库
JSP标准模板库(下)
Web-第十二天 el&jstl表达式学习
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服