1. 首先需要两个JAR包 jstl.jar standard.jar
2. JSP页面头部
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
JAVA代码
List list = new ArrayList();
for(int i=1;i<9;i++){
list.add("str"+i);
}
request.setAttribute("list",list);
页面代码
<c:forEach items="${list}" var="item">
${item}
</c:forEach>
<%@ page isELIgnored="false" %> 目的是使EL表达式可用。
参考地址:http://wushuicheng.iteye.com/blog/875753
本文详细介绍了如何在JSP页面中利用JSTL库中的<c:forEach>标签进行数据遍历,并结合EL表达式获取和展示数据,通过实例展示了循环遍历的基本用法。

被折叠的 条评论
为什么被折叠?



