-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet_object_data.jsp
More file actions
118 lines (100 loc) · 2.58 KB
/
Get_object_data.jsp
File metadata and controls
118 lines (100 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<%@ page import="domain.User" %>
<%@ page import="java.util.*" %>
<%--
User: cpucode
Date: 2020/12/19
Time: 16:56
Github: https://github.com/CPU-Code
CSDN: https://blog.csdn.net/qq_44226094
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>el获取对象数据</title>
</head>
<body>
<%
User user = new User();
user.setId(1);
user.setName("北鼻");
user.setMoney(9999);
user.setBirthday(new Date());
request.setAttribute("u", user);
List list = new ArrayList();
list.add("cpu");
list.add("cpucode");
list.add(user);
request.setAttribute("list", list);
Map map = new HashMap();
map.put("mname", "不知妻美");
map.put("gender", "男");
map.put("user", user);
request.setAttribute("map", map);
%>
<%--
获取对象、List集合、Map集合的值
1. 对象:${域名称.键名.属性名}
* 本质上会去调用对象的getter方法
2. List集合:${域名称.键名[索引]}
3. Map集合:
* ${域名称.键名.key名称}
* ${域名称.键名["key名称"]}
--%>
<%--
* 通过的是对象的属性来获取
* setter或getter方法,去掉set或get,在将剩余部分,首字母变为小写。
* setName --> Name --> name
--%>
<h3>el获取对象中的值</h3>
\${requestScope.u} = ${requestScope.u}
<br>
\${requestScope.u.id} = ${requestScope.u.id}
<br>
\${u.name} = ${u.name}
<br>
\${u.money} = ${u.money}
<br>
\${u.birthday} = ${u.birthday}
<br>
\${u.birStr} = ${u.birStr}
<br>
<h3>el获取List值</h3>
\${list} = ${list}
<br>
\${list[0} = ${list[0]}
<br>
\${list[1} = ${list[1]}
<br>
\${list[2} = ${list[2]}
<br>
\${list[3} = ${list[3]}
<br>
\${list[2].id} = ${list[2].id}
<br>
\${list[2].name} = ${list[2].name}
<br>
\${list[2].money} = ${list[2].money}
<br>
\${list[2].birthday} = ${list[2].birthday}
<br>
\${list[2].birStr} = ${list[2].birStr}
<br>
<h3>el获取Map值</h3>
\${map.mname} = ${map.mname}
<br>
\${map.gender} = ${map.gender}
<br>
\${map["geder"]} = ${map["geder"]}
<br>
\${map.user.id} = ${map.user.id}
<br>
\${map.user.name} = ${map.user.name}
<br>
\${map.user.money} = ${map.user.money}
<br>
\${map.user.birthday} = ${map.user.birthday}
<br>
\${map.user.birStr} = ${map.user.birStr}
<br>
</body>
</html>