| <body> This is my JSP page. <br> <% request.setAttribute("request_attribute", "request_haha"); %> ${request_attribute } </body> |

| <body> This is my JSP page. <br> <% pageContext.setAttribute("attribute", "pageContext_haha"); session.setAttribute("attribute", "session_haha"); application.setAttribute("attribute", "application_haha"); request.setAttribute("attribute", "request_haha"); %> ${attribute } </body> |





| <body> This is my JSP page. <br> <% request.setAttribute("attribute", "request_haha"); pageContext.setAttribute("attribute", "pageContext_haha"); session.setAttribute("attribute", "session_haha"); application.setAttribute("attribute", "application_haha"); %> <p>全域查找:${attribute }</p> <p>从page域中查找:${pageScope.attribute }</p> <p>从request域中查找:${requestScope.attribute }</p> <p>从session域中查找: ${sessionScope.attribute }</p> <p>从application域中查找:${applicationScope.attribute }</p> </body> |

| public class Address { private String city; private String street; 此处省略Address类的成员变量的get/set方法 @Override public String toString() { return "Address [city=" + city + ", street=" + street + "]"; } } |
| public class Employee { private String name; private double salary; private Address address; 此处省略Employee类的成员变量的get/set方法 @Override public String toString() { return "Employee [name=" + name + ", salary=" + salary + ", address=" + address + "]"; } } |
| <%@ page import="cn.itcast.domain.*" %><!—由于在跟页面中需要使用Address,Employee类,所以这里需要将它们导入--> <body> <% Address address = new Address(); address.setCity("北京"); address.setStreet("西三旗"); Employee emp = new Employee(); emp.setName("李小四"); emp.setSalary(123456); emp.setAddress(address); request.setAttribute("emp", emp); %> <h3>使用el获取request域的emp</h3> ${requestScope.emp }<br/> </body> |

| ... ... <h3>使用el获取request域的emp对象的address属性的street属性</h3> ${requestScope.emp.address.street} ... ... |

| 此处省略例1-5中的代码 public String getHehe() { return "我去..."; } |
| 此处省略例1-6中的代码 ${emp.hehe } |

| 运算符 | 说明 | 范例 | 结果 |
| + | 加 | ${17+5} | 22 |
| - | 减 | ${17-5} | 12 |
| * | 乘 | ${17*5} | 85 |
| /或div | 除 | ${17/5}或${17 div 5} | 3 |
| %或mod | 取余 | ${17%5}或${17 mod 5} | 2 |
| ==或eq | 等于 | ${5==5}或${5 eq 5} | true |
| !=或ne | 不等于 | ${5!=5}或${5 ne 5} | false |
| <或lt | 小于 | ${3<5}或${3 lt 5} | true |
| >或gt | 大于 | ${3>5}或${3 gt 5} | false |
| <=或le | 小于等于 | ${3<=5}或${3 le 5} | true |
| >=或ge | 大于等于 | ${3>=5}或${3 ge 5} | false |
| &&或and | 并且 | ${true&&false}或${true and false} | false |
| !或not | 非 | ${!true}或${not true} | false |
| ||或or | 或者 | ${true||false}或${true or false} | true |
| empty | 是否为空 | ${empty “”},可以判断字符串、数据、集合的长度是否为0,为0返回true。empty还可以与not或!一起使用。${not empty “”} | true |
| 欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |