Latest web development tutorials

<C: if> tag

JSP standard Tag Library JSP standard Tag Library

<C: if> jugement expression de valeur d'étiquette, si l'expression est évaluée à true exécute son contenu principal.

syntaxe

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

propriété

<C: if> tag possède les attributs suivants:

propriété description le cas échéant Par défaut
test condition il est aucun
var Etat de variables sont utilisées pour stocker le résultat aucun aucun
portée attribut var Scope aucun page

La démonstration

<%@ 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>

Les résultats sont les suivants:

我的工资为: 4000

JSP standard Tag Library JSP standard Tag Library