jsp常见jstl语法(二)
<c:choose>标签与Javascript switch语句的功能一样,用于在众多选项中做出选择。
语法格式
<c:choose>
<c:when test="<boolean>">
...
</c:when>
<c:when test="<boolean>">
...
</c:when>
...
...
<c:otherwise>
...
</c:otherwise>
</c:choose>属性
<c:choose></c:choose>和<c:otherwise></c:otherwise>没有属性
<c:otherwise></c:otherwise>属性只有test如下表
| 属性 | 描述 | 是否必要 | 默认值 |
| test | 条件 | 是 | 无 |
我来举个例子:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<title>c:choose 标签实例</title>
</head>
<body>
<c:set var="salary" value="15000"/>
<p>你的工资为 : <c:out value="${salary}"/></p>
<c:choose>
<c:when test="${salary <= 1000}">
太惨了,对你表示同情,但又无可奈何。
</c:when>
<c:when test="${salary > 10000}">
不错的薪水,还能生活。
</c:when>
<c:otherwise>
什么都没有。
</c:otherwise>
</c:choose>
</body>
</html> 相关推荐
登峰小蚁 2019-10-26
白净垃圾桶 2013-09-16
MicroBoy 2012-06-13
homesmile 2014-07-05
字符串过于长的时候需要通过仅仅展示前4个,用...表示省略,<c:if test="${fn:length<=5}">${word.type}</c:if>href触发JavaScript事件:。<a
cyjsky 2013-03-27
谢恩铭 2013-01-14
detianlangzi 2009-12-16
owhile 2012-09-10
dinux 2012-08-25
南鹏飞技术 2011-07-05
yixu0 2011-05-08
wuhuang 2011-11-15
Astray 2009-06-15
appteamvlctech 2013-11-06