JSTL 的<c:if>标签没有else的解决办法
2024-09-05 15:56:32
我们可以采用<c:choose>来代替<c:if>
具体结构:
<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"/> 范例说明:当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>成立。
</c:otherwise> </c:choose>
最新文章
- yum源配置与使用
- js中的forEach
- C#异常类相关总结
- Hbase原理、基本概念、基本架构
- Ajax编程中,经常要能动态的改变界面元素的样式
- Residual Networks <;2015 ICCV, ImageNet 图像分类Top1>;
- nyoj---t448(寻找最大数)
- 转: Android开发中的MVP架构详解(附加链接比较不错)
- [CC150] Get all permutations of a string
- centos安装svn
- python绝技 — 嗅探FTP登录口令
- ProjectManager Beta 2 项目管理器发布
- ssm开发使用redis作为缓存,使用步骤
- .Net Core下 Redis的String Hash List Set和Sorted Set的例子
- There are multiple modules with names that only differ in casing. 黄色warning
- TopCoder SRM502 Div1 1000 动态规划
- getOutputStream与getWriter方法
- [uwsgi: command not found]
- Python 初识网络
- 【struts2】action中使用通配符
热门文章
- python学习之路(17)
- RedisTemplate集合使用说明-opsForList(二)
- iOS检测QQ是否安装
- C++入门经典-例5.10-指针作为返回值
- LeetCode 12. 整数转罗马数字(Integer to Roman)
- 百度echars 插件 横坐标信息倾斜显示
- weblogic报:java.lang.LinkageError: loader constraint violation in interface itable initialization
- Application 使用分析
- Go语言程序结构
- Selenium 2自动化测试实战8(控制浏览器)