Latest web development tutorials

<C: if> tag

JSP Standard Tag Library JSP Standard Tag Library

<C: if> tag value judgment expression, if the expression evaluates to true executes its main content.

Syntax

<c:if test="<boolean>" var="<string>" scope="<string>">
   ...
</c:if>

Attributes

<C: if> tag has the following attributes:

Attributes description If necessary Defaults
test condition Yes no
var Condition variables are used to store the result no no
scope Scope var attribute no page

The demonstration

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>c:if 标签实例</title>
</head>
<body>
<c:set var="salary" scope="session" value="${2000*2}"/>
<c:if test="${salary > 2000}">
   <p>我的工资为: <c:out value="${salary}"/><p>
</c:if>
</body>
</html>

Results are as follows:

我的工资为: 4000

JSP Standard Tag Library JSP Standard Tag Library