<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.HashMap" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<h3>set的使用 SET标签</h3>
<c:set var="name" value="蔡恒" scope="request"/>
${name}
<h3>c:if标签的使用</h3>
<c:set var="score" value="85" scope="request"/>
<c:if test="${score >=80 and score<=100}">
你真厉害
</c:if>
<h3>foreach遍历</h3>
<%
ArrayList<String> arr = new ArrayList<>();
arr.add("操作");
arr.add("曹操");
arr.add("赵云");
arr.add("李白");
request.setAttribute("arr",arr);
%>
<c:forEach items="${arr}" var="name">
${name}
</c:forEach>
<h3>遍历域中的map集合</h3>
<%
HashMap<String, String> map = new HashMap<>();
map.put("name","赵云");
map.put("age","56");
map.put("addr","北京");
map.put("desc","是中国的首都");
request.setAttribute("Map",map);
%>
<c:forEach items="${Map}" var="entry">
${entry.getValue()}
<br>
${entry.key}:${entry.value}
</c:forEach>
</body>
</html>
标签:map,arr,name,学习,add,jsp,put,entry
From: https://www.cnblogs.com/ch2020/p/16886110.html