c:forEach
相当于for循环
- items:被遍历的容器
- var:遍历产生的临时变量
- varStatus:遍历状态对象
- begin:开始数
- end:结束数
- step:步长
<%--
Created by IntelliJ IDEA.
User: guigui
Date: 2022/3/29
Time: 9:50
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page isELIgnored="false" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%--
c:if:来完成逻辑判断,替换java if else
--%>
<c:if test="${status == 1}">
启用
</c:if>
<c:if test="${status == 0}">
禁用
</c:if>
<c:forEach items="${brands}" var="brand">
<tr align="center">
<td>${brand.id}</td>
<td>${brand.brand_name}</td>
<td>${brand.company_name}</td>
<td>${brand.description}</td>
</tr>
</c:forEach>
</body>
</html>
req.getRequestDispatcher("/jstl_foreach.jsp").forward(req,resp);