JSTL
java Server Pages Standard Tag Libray(JSTL):JSP 标准标签库,是⼀个定制标签类库的集合,⽤于
解决⼀些常⻅的问题
环境搭建
1.添加坐标依赖 jstl starded
2.在页面中引入 <%@taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c”%>
–%>
标签的使用
条件动作标签
if标签
语法
<c:if test="<boolean>" var="<string>" scope="<string>">
...
</c:if>
属性
test 条件
var ⽤于存储条件结果的变量(限域变量名)
scope:
var属性的作⽤域 ,可取值:page|request|session|application,默认值是page
<%
request.setAttribute("flag",true);
request.setAttribute("num",1);
%>
<c:if test="${flag}">
<p>结果为true<p>
</c:if>
<c:if test="