<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ page isELIgnored="false" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>标签库实例</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <h4><c:out value="forEach实例"></c:out></h4> <hr> <% String item[]=new String[5]; item[0]="核心标签库"; item[1]="国际化签库"; item[2]="SQL标签库"; item[3]="XML标签库"; item[4]="函数标签库"; request.setAttribute("item", item); %> <b><c:out value="不指定begin和end的迭代"></c:out></b><br> <c:forEach var="item" items="${item }"> <c:out value="${item }"/><br></c:forEach> <b> <c:out value="指定begin和end的迭代"/></b><br> <c:forEach var="item" items="${item }" begin="1" end="3" step="1" varStatus="s"> <c:out value="${item }"/><br> </c:forEach> <b><c:out value="输出整个迭代的信息"/></b><br> <c:forEach var="item" items="${item }" begin="3" end="4" step="1" varStatus="s"> <c:out value="${item }"/>的四种属性:<br> 所在位置,即索引:<c:out value="${s.index }"/><br> 总共迭代次数:<c:out value="${s.count }"/><br> 是否为第一个值:<c:out value="${s.first }"/><br> 是否为最后一个值:<c:out value="${s.last }"/><br> </c:forEach> </body> </html>
时间: 2024-10-11 23:27:26