<!-- 用el获取javabean -->
<%
Girl girl = new Girl("莹莹",18);
request.setAttribute("girl", girl);
%>
${girl}
${girl.age}<!-- 相当于调用了getAge() -->
${girl.name}<!-- 相当于调用了getName() -->
<hr/>
<!-- 取出list集合 -->
<%
List list = new ArrayList();
list.add("aaa");
list.add("bbb");
list.add("ccc");
request.setAttribute("list", list);
%>
${ list}
${ list[0]}
${ list[1]}
${ list[2]}
<hr/>
<!-- 取出map集合 -->
<%
Map map = new HashMap();
map.put("aaa","111");
map.put("bbb","222");
map.put("ccc","333");
request.setAttribute("map2", map);
%>
${map2 }
${map2.aaa }
${map2.bbb }
${map2["aaa"] }
<hr/>
<!-- 取出数组 -->
<%
String[] args = {"111","222","333"};
request.setAttribute("names", args);
%>
${names}
${names[0]}
${names[1]}
${names[2]}
网友评论