<%@page import="java.util.HashMap"%> <%@page import="java.util.List"%> <%@page import="java.util.ArrayList"%> <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>EL表达式</title> </head> <body> <jsp:useBean id="person" class="com.itheima.domain.Person"></jsp:useBean> <jsp:setProperty property="name" name="person" value="李四"/> <jsp:setProperty property="age" name="person" value="18"/> <jsp:setProperty property="sex" name="person" value="男"/> <br/>--------------------jsp输出---------------------<br/> <%=person.getName()+person.getAge()+person.getSex() %> <br/>--------------------EL获取对象的属性---------------------<br/> ${person.name }${person.age }${person.sex } <br/>--------------------EL获取有序集合的元素---------------------<br/> <% List list=new ArrayList(); list.add("早上好"); list.add("中午好"); list.add("晚上好"); request.setAttribute("list", list); %> ${list[0] }${list[1] } <br/>--------------------EL获取map集合中的元素---------------------<br/> <% HashMap map=new HashMap(); map.put("name", "张三"); map.put("age","20"); request.setAttribute("map", map); %> 姓名:${map.name }年龄:${map.age } <br/>------EL小应用----<br/> <%request.setAttribute("sex", "0"); %> <form action="" method="get"> <input type="radio" name="sex" value="1" ${ sex=="1"?"checked='checked'":""}/>男 <input type="radio" name="sex" value="0" ${ sex=="0"?"checked='checked'":""}/>女 用到了二元表达式 </form> </body> </html>