jsp 标准标签库之<c:if>

来源:互联网 发布:淘宝上的情蛊靠谱吗 编辑:程序博客网 时间:2024/05/18 02:03

<c:if>标签主要用来判断语句

语法:

<c:if test="判断条件" var="存储判断结果" [scope="page|request|session|application"]>

               满足条件是执行的语句

</c:if>

属性表:

test:用于判断条件,如果条件为true,则执行标签体的内容

var:保存判断的结果

scope:制定判断结果保存的范围,默认值为page

示例:

<%@page contentType="text/html" pageEncoding="GBK"%>

<%@ taglib url="http://www.mlldn.cn/jstl/core" prefix="c"%>

<html>

<head>

<title>jsp标签库</title>

</head>

<body>

        <c:if test="${param.ref=='mldn'}" var="res1" scope="page">

        <h1>欢迎${param.ref}光临!</h1>

        </c:if>

       <c:if test="${10<30}" var="res2" >

        <h2>10比30小</h2>

        </c:if>


</body>

</html>


补充:

<C:choose>



0 0