获取域中存储List集合和Map集合的值
list集合:${域名称.键名[索引]}
jsp代码
<%@ page import="java.util.ArrayList" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>获取域中存储List集合的值</title> </head> <body> <% ArrayList list = new ArrayList(); list.add("aaa"); list.add("bbb"); request.setAttribute("list",list); %> <h3>获取List集合的值</h3> ${list}<br> ${list[0]}<br> ${list[1]}<br> </body> </html>
运行结果
map集合:
${域名称.键名.key名称}
${域名称.键名[key名称]}
jsp代码
<%@ page import="java.util.ArrayList" %> <%@ page import="java.util.Map" %> <%@ page import="java.util.HashMap" %> <%@ page import="com.bai.dao.User" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>获取域中存储map集合的值</title> </head> <body> <% Map map=new HashMap(); map.put("sname","李四"); map.put("gender","男"); request.setAttribute("map",map); %> <h3>获取map集合的值</h3> ${map.gender}<br> ${map["gender"]}<br> </body> </html>
运行结果
标签:Map,键名,map,List,list,获取,集合 From: https://www.cnblogs.com/aimz01/p/16592299.html