首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

JSTL 惟独c:if 而没有 c:else

2012-10-06 
JSTL 只有c:if 而没有 c:else在jsp中 我们可以在 《% %》中写if(){}else{} 但是 jstl 只有c:if 而没有 c:els

JSTL 只有c:if 而没有 c:else
在jsp中 我们可以在 《% %》中写if(){}else{} 但是 jstl 只有c:if 而没有 c:else



但jstl 提供了 <c:choose>标签 来满足我们的需求

<c:choose>

   <c:when test=''>    如果
   </c:when>
  
   <c:otherwise>  否则
   </c:otherwise>
 
</c:choose>
例如 我写了如下代码:

<c:choose>
      <c:when test='${'list_dan' eq class1}'>
        <c:set var='class1' value='list_on'></c:set>
      </c:when>
      <c:otherwise>
       <c:set var='class1' value='list_dan'></c:set>
      </c:otherwise>
</c:choose>

热点排行