小白教程
所有教程
关于
Search
172.70.126.166
172.70.126.166
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Jstl core if tag”的源代码
本页内容
上一节:
Jstl_core_catch_tag
下一节:
Jstl_core_choose_tag
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:<c:if>}}[[Category:jsp jstl|5]] = <c:if> 标签 = [[jsp jstl|JSP 标准标签库]] <c:if>标签判断表达式的值,如果表达式的值为 true 则执行其主体内容。 === 语法格式 === <sample title="" desc="" lang="jsp" hererun="1"> <c:if test="<boolean>" var="<string>" scope="<string>"> ... </c:if> </sample> === 属性 === <c:if>标签有如下属性: {| class="table table-striped table-hover" ! '''属性''' ! '''描述''' ! '''是否必要''' ! '''默认值''' |- | test | 条件 | 是 | 无 |- | var | 用于存储条件结果的变量 | 否 | 无 |- | scope | var属性的作用域 | 否 | page |} == 演示实例 == <sample title="" desc="" lang="jsp" hererun="1"> <%@ 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> </sample> 运行结果如下: <sample title="" desc="" lang="jsp" hererun="1"> 我的工资为: 4000 </sample> [[jsp jstl|JSP 标准标签库]]
返回至“
Jstl core if tag
”。
上一节:
Jstl_core_catch_tag
下一节:
Jstl_core_choose_tag