JSTL标签之<c:choose><c:when><c:otherwise>标签

假设是JSTL1.1版本号,使用<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
否则的话,假设是JSTL1.0版本号,使用<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>,另外须要在项目中导入JSTL和standard两个jar包。
<c:choose><c:when><c:otherwise>标签的使用必须符合下面语法规则:   
<c:when><c:otherwise>不能单独使用。它们必须位于<c:choose>父标签中。
在<c:choose>标签中能够包括一个或多个<c:when>标签。
在<c:choose>标签中能够不包括<c:otherwise>标签。

<c:choose>标签中假设同一时候包括<c:when><c:otherwise>标签,那么<c:otherwise>必须位于<c:when>标签之后。 假设须要推断session中的某个对象是否非空<c:when test="${!empty session.user}"> 同理。假设要推断空<c:when test="${empty session.user}">

【推广】 免费学中医,健康全家人
原文地址:https://www.cnblogs.com/llguanli/p/8888712.html