JSTL 的 if else : 有 c:if 没有 else 的处理
来源:互联网 发布:mac电脑图片预览 编辑:程序博客网 时间:2024/05/17 12:03
jstl的c:if 没有else
想要实现if...else...:
可以用下面的解决
--------------------------------------------------------------------
结构:
<c:choose>
<c:when test=""> 如果
</c:when>
<c:otherwise> 否则
</c:otherwise>
</c:choose>
代码:
<c:choose> <c:when test="${sessionScope.USERTYPE == 'inner'}"> <c:set value="${context_root}/igmgr/MEB004.dow" var="action" scope="page"/> </c:when> <c:when test="${sessionScope.USERTYPE == 'merc'}"> <c:set value="${context_root}/igmgr/MEB021.dow" var="action" scope="page"/> </c:when> <c:otherwise> <c:set value="${context_root}/igmgr/MEB020.dow" var="action" scope="page"/> </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>成立。
- JSTL 的 if else : 有 c:if 没有 else 的处理
- JSTL 的 if else : 有 c:if 没有 else 的处理
- JSTL 的 if else : 有 c:if 没有 else 的处理
- JSTL 的 if else : 有 c:if 没有 else 的处理
- JSTL 的 if else : 有 c:if 没有 else 的处理
- JSTL 的 if else : 有 c:if 没有 else 的处理
- JSTL 的 if else : 有 c:if 没有 else 的处理
- jstl 的<c:if>标签没有else的解决办法
- C标签中jstl的if else
- jstl的if...else使用
- JSTL中解决c:if没有else
- <c:if>没有else
- 如何实现JSTL if else if else 的jsp标签
- C标签的if else
- if......if和if......else if......else if的区别
- if , if else , if else if , if的嵌套
- if,else if,else的执行
- if else if else 语句的拓展
- JSP中Session的使用
- 移行短信需求
- 堆与栈
- centOS yum 安装mysql
- 整型数组处理算法(二)文件中有一组整数,要求排序后输出到另一个文件中
- JSTL 的 if else : 有 c:if 没有 else 的处理
- flash实用类库
- R语言之常用函数
- ubuntu 12.04 安装wireshar后,找不到设备
- [基础]SQL语句执行效率及分析
- jsp的application技术整理
- 按字节、位、字寻址
- 【转载】随机函数生成问题
- MongoDB——第八天 驱动实践