code096.jsp
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>EL表达式获取List集合的数据</title>
</head>
<body>
<%
List<String> list1 = new ArrayList<String>();
list1.add("面包");
list1.add("牛奶");
list1.add("钞票");
session.setAttribute("goods", list1);
%>
<%
List<String> list2 = (List<String>)session.getAttribute("goods");
for(int i=0;i<list2.size();i++)
{
request.setAttribute("index", i);
%>
${index}: ${goods[index]}<br>
<%
}
%>
</body>
</html>