jstl c:choose>、<c:when>和<c:otherwise>标签
来源:互联网 发布:怎样注册一个域名 编辑:程序博客网 时间:2024/06/12 19:16
在用spring mvc中,页面前端老用jstl,记录一下。
<c:choose>、<c:when>和<c:otherwise>在一起连用,可以实现Java语言中的if-else语句的功能。例如以下代码根据username请求参数的值来打印不同的结果:
<c:choose>
<c:when test="${empty param.username}">
Nnknown user.
</c:when>
<c:when test="${param.username=='Tom'}">
${param.username} is manager.
</c:when>
<c:otherwise>
${param.username} is employee.
</c:otherwise>
</c:choose>
以上标签等价于以下Java程序片段:
<%
String username=request.getParameter("username");
if(username==null){
//对应第一个<c:when>标签的主体
out.print("Nnknown user.");
}else if(username.equals("Tom")){
//对应第二个<c:when>标签的主体
out.print(username+" is manager.");
}else{
//对应<c:otherwise>标签的主体
out.print(username+" is employee.");
}
%>
<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>标签之后。
更详细的查看(各种标签的使用):
http://www.tutorialspoint.com/jsp/jsp_standard_tag_library.htm
- jstl <c:choose></c:choose>,<c:when></c:when>和<c:otherwise></c:otherwise>标签用法
- jstl c:choose>、<c:when>和<c:otherwise>标签 [转]
- jstl c:choose>、<c:when>和<c:otherwise>标签
- jstl c:choose>、<c:when>和<c:otherwise>标签
- jstl c:choose>、<c:when>和<c:otherwise>标签
- jstl c:choose>、<c:when>和<c:otherwise>标签
- JSTL标签之<c:choose><c:when><c:otherwise>标签
- jstl c:choose><c:when><c:otherwise>标签
- JSTL<c:choose>, <c:when>, <c:otherwise> 标签
- <c:choose> <c:when> <c:otherwise>--------JSTL
- 【c标签】 c:choose、c:when和c:otherwise标签
- <c:choose>, <c:when>, <c:otherwise> 标签
- <c:choose>, <c:when>, <c:otherwise> 标签
- Html标签:/c:choose/、/c:when/和/c:otherwise/
- <c:choose>、<c:when>和<c:otherwise>
- jsp页面中jstl标签详解 包括< c:choose><c:foreach> <c:when> <c:otherwise>
- jsp页面中jstl标签详解 包括< c:choose> <c:when> <c:otherwise> <c:if>等
- <c:when> <c:otherwise> <c:choose> 嵌套 遍历 jstl
- 零基础入门深度学习(2)
- 单表的CURD操作(使用mapper动态代理)
- 蓝桥杯 ALGO-104 算法训练 阿尔法乘积
- TIANKENG’s restaurant HDU
- 测试
- jstl c:choose>、<c:when>和<c:otherwise>标签
- 零基础入门深度学习(3)
- 微信扫码支付
- mysql中int、bigint、smallint 和 tinyint的区别详细介绍
- 时间复杂度(数据结构笔记)
- 守护进程
- 零基础入门深度学习(4)
- ssh的安装
- 蓝桥杯 ALGO-102 算法训练 数对