EL表达式
EL
获取page、request、session、application对象中的数据
- 语法:${}
- 读取顺序:page>request>session>application
<%
pageContext.setAttribute("name","page");
request.setAttribute("name","request");
session.setAttribute("name","session");
application.setAttribute("name","application");
%>
${name} ---结果为page
- 特殊读取:$
${requestScope.name}
${pageScope.name}
${sessionScope.name}
${applicationScope.name}
- 使用注意:只能使用在jsp页面
- 及联获取:可获取对象的属性,但必须要有get方法,${user.xxxx}或者$
<%
User user = new User("1","claudxyz",20);
pageContext.setAttribute("user",user);
%>
${user}
<table border="1">
<tr>
<th>用户号</th>
<th>姓名</th>
<th>年龄</th>
</tr>
<tr>
<td>${user.id}</td>
<td>${user.name}</td>
<td>${user.age}</td>
</tr>
</table>
- EL执行表达式
&& || ! != == < > <= >=
&& and
|| or
! not
== eq
!= ne
< lt
> gt
<= le
>= ge
empty

浙公网安备 33010602011771号