- List集合:${域名称.键名[索引]}
- 例如 ${requestScope.list.get(0)}
<%@ page import="java.util.ArrayList" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%
ArrayList<String> list = new ArrayList<String>();
list.add("aaa");
list.add("bbb");
request.setAttribute("list",list);
%>
${list}<br><br><br>
<hr>
${list[0]}<br><br><br>
${list[1]}<br><br><br>
<hr>
${requestScope.list.get(0)}<br><br><br>
${requestScope.list.get(1)}<br><br><br>
<hr>
${requestScope.list[1]}<br><br><br>
${requestScope.list[0]}<br><br><br>
</body>
</html>
- Map集合:${域名称.键名.key名}
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.HashMap" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%
HashMap<String, String> map = new HashMap<>();
map.put("name","张三");
map.put("age","14");
request.setAttribute("map",map);
%>
${requestScope.map}<br><br>
${map}<br><br>
${map.name}<br><br>
${map.age}<br><br>
${requestScope.map.name}<br><br>
${requestScope.map.age}<br><br>
</body>
</html>
标签:EL,map,requestScope,get,list,集合,Map
From: https://www.cnblogs.com/ailhy/p/16591628.html