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
|
<%@ page language=
"java"
import=
"java.util.*"
pageEncoding=
"UTF-8"
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+
"://"
+request.getServerName()+
":"
+request.getServerPort()+path+
"/"
;
%>
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
>
<html>
<head>
<base href=
"<%=basePath%>"
>
<title>My JSP
'test3.jsp'
starting page</title>
<meta http-equiv=
"pragma"
content=
"no-cache"
>
<meta http-equiv=
"cache-control"
content=
"no-cache"
>
<meta http-equiv=
"expires"
content=
"0"
>
<meta http-equiv=
"keywords"
content=
"keyword1,keyword2,keyword3"
>
<meta http-equiv=
"description"
content=
"This is my page"
>
<!--
<link rel=
"stylesheet"
type=
"text/css"
href=
"styles.css"
>
-->
<script src=
"js/jquery-2.1.1.min.js"
></script>
<script>
//模拟map
function
Map(){
var
object={};
//空的对象,用于承载键值对
this
.put=
function
(key,value){
object[key]=value;
//把键值对绑定到object上
}
this
.size=
function
(){
var
count=0;
for
(
var
attr
in
object){
count++;
}
return
count;
}
this
.get=
function
(key){
if
(object[key]||object[key]===0||object[key]===
false
){
return
object[key];
}
else
{
return
null
;
}
}
this
.remove=
function
(key){
if
(object[key]||object[key]===0||object[key]===
false
){
delete
object[key];
}
}
this
.eachmap=
function
(fn){
for
(
var
attr
in
object){
fn(attr,object[attr]);
}
}
}
var
map=
new
Map();
map.put(
'1'
,
'1'
);
map.put(
'2'
,
'2'
);
map.put(
'3'
,
'3'
);
alert(map.size());
alert(
'2'
);
map.eachmap(
function
(key,value){
alert(key+
":"
+value);
});
</script>
</head>
<body>
This is my JSP page. <br>
</body>
</html>
|
本文转自 matengbing 51CTO博客,原文链接:http://blog.51cto.com/matengbing/1878720