jsp中如何用jstl实现if(){}else if(){}else{}

<c:choose>
<c:when test="${条件}">
情况1...........
</c:when>
<c:when test="${条件}">
 情况2...........
</c:when>
<c:otherwise>
否则。。。。。
</c:otherwise>
</c:choose>

jstl中if语句

<c:if>标签计算表达式,只有当表达式的值为true,则显示其主体内容。

属性:

<c:if>标签具有以下属性:

属性描述必需默认
test 条件计算 Yes None
var 变量名称的存储条件的结果 No None
scope 变量的范围的存储条件的结果 No page

例子:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title><c:if> Tag Example - www.yiibai.com</title>
</head>
<body>
<c:set var="salary" scope="session" value="${2000*2}"/>
<c:if test="${salary > 2000}">
   <p>My salary is: <c:out value="${salary}"/><p>
</c:if>
</body>
</html>

这将产生以下结果:

My salary is: 4000

 

 

 

posted on 2016-08-19 11:48  让编程成为一种习惯  阅读(6258)  评论(0编辑  收藏  举报