自强学堂
自强学堂:学习、分享、让你更强!
JSP 教程HTMLCSSJAVASCRIPTJQUERYSQLPHPBOOTSTRAPANGULARXML
 

<c:if> 标签

<c:if>标签判断表达式的值,如果表达式的值为真则执行其主体内容。

属性

<c:if>标签有如下属性:

属性描述是否必要默认值
test 条件
var 用于存储条件结果的变量
scope var属性的作用域 page

演示实例

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title><c:if> Tag Example</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