标签:arraylist attribute htm title jstl tty har add import
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>jstl中foreach标签</title>
</head>
<body>
<c:forEach begin="1" end="10" var="i" step="1" varStatus="s">
${i}<br/>
</c:forEach>
<hr>
<c:forEach begin="1" end="10" var="i" step="2" varStatus="s">
${i}/${s.index}/${s.count} <br/>
</c:forEach>
<hr>
<%
List list = new ArrayList();
list.add("aaa");
list.add("bbb");
list.add("ccc");
request.setAttribute("list",list);
%>
<c:forEach items="${list}" var="str" varStatus="s">
${s.index}/${s.count}/${str} <br/>
</c:forEach>
</body>
</html>
标签:arraylist attribute htm title jstl tty har add import
原文地址:https://www.cnblogs.com/newcityboy/p/11478948.html