jstl标签 c:if和c:choose

代码  收藏代码
  1. <c:if test="${test == null}">test为null</c:if>  


其意思是,如果test 为 null,那么就打印 “test为null” 

那么如果有两个以上的条件呢? 
那么就可以用<c:choose>了,其使用方法: 

代码  收藏代码
  1. <c:choose>   
  2.   <c:when test="expression">   
  3.         body content   
  4.   </c:when>   
  5.   <c:when test="expression">   
  6.         body content   
  7.   </c:when>   
  8.   ...   
  9.   <c:otherwise>   
  10.         body content   
  11.   </c:otherwise>   
  12. </c:choose>   


相当于java 语言的switch case用法,进来一个变量,根据不同判断,得到最终的一个结果

原文地址:https://www.cnblogs.com/cai170221/p/7250333.html