1,EL表达式语言内置对象
No | 内置对象 | 描述 |
---|
1 | pageContext | 代表该页面的pageContext对象,与JSP的pageContext内置对象相同 |
2 | pageScope | 用于获取page范围的属性值 |
3 | requestScope | 用于获取request范围的属性值 |
4 | sessionScope | 用于获取session范围的属性值 |
5 | applicationScope | 用于获取application范围的属性值 |
6 | param | 用于获取请求的参数值 |
7 | paramValues | 用于获取请求的参数值,与param的区别在于,该对象用于获取属性值为数组的属值 |
8 | header | 用于获取请求头的属性值 |
9 | headerValues | 用于获取请求头的属性值,与header的区别在于,该对象用于获取属性值为数组的属性值 |
10 | initParam | 用于获取请求Web应用的初始化参数 |
11 | cookie | 用于获取指定的Cookie值 |
<%
request.setAttribute("info","www.baidu.com");
if(request.getAttribute("info")!= null){
%>
<h3><%=request.getAttribute("info") %></h3>
<%
}
%>
<h3>${info}</h3>
<%
pageContext.setAttribute("info","page属性范围");
request.setAttribute("info","request属性范围");
session.setAttribute("info","session属性范围");
application.setAttribute("info","application 属性范围");
%>
<h3>page 属性内容:${ pageScope.info}</h3>
<h3>request 属性内容:${ requestScope.info}</h3>
<h3>session 属性内容:${ sessionScope.info}</h3>
<h3>application 属性内容:${ applicationScope.info}</h3>
<%
List all = new ArrayList();
all.add("李丹");
all.add("www.baidu.com");
all.add("www.baidu.com");
all.add("www.baidu.com");
request.setAttribute("allinfo",all);
Map map = new HashMap();
map.put("id","李丹");
map.put("site","www.baidu.com");
map.put("email","2001@qq.com");
request.setAttribute("mapinfo",map);
%>
<h3>第一个元素:${allinfo[0] } </h3>
<h3>第二个元素:${allinfo[1] } </h3>
<h3>第三个元素:${allinfo[2] } </h3>
<h3>第四个元素:${allinfo[3] } </h3>
<br/><br/><br/>
<h3>第一个元素:${mapinfo["id"] } </h3>
<h3>第二个元素:${mapinfo.site } </h3>
<h3>第一个元素:${mapinfo["email"] } </h3>
2,EL表达式的运算符
<%-------------------------EL表达式 运算符----------------------- --%>
<h3>${20+30} </h3>
<h3>${20-30} </h3>
<h3>${20*30} </h3>
<h3>${20/30} </h3>
<h3>${20%30} </h3>
<%
pageContext.setAttribute("a",20);
pageContext.setAttribute("b",30);
pageContext.setAttribute("c",3);
pageContext.setAttribute("flag1",true);
pageContext.setAttribute("flag2",false);
%>
<h3>加 :${a+b} </h3>
<h3>减:${a-b} </h3>
<h3>乘:${a*b} </h3>
<h3>除:${a/b} </h3>
<h3>取模:${a%b} </h3>
<h3>等于 : ${a==b} 和和和和和 ${a eq b} </h3>
<h3>不等于: ${a!=b} 和和和和和 ${a ne b} </h3>
<h3>小于: ${a<b} 和和和和和 ${a lt b} </h3>
<h3>大于: ${a>b} 和和和和和 ${a gt b} </h3>
<h3>小于等于: ${a<=b} 和和和和和 ${a le b} </h3>
<h3>大于等于: ${a>=b} 和和和和和 ${a ge b} </h3>
<h3>与操作: ${flag1 && flag2} 和和和和和 ${flag1 and flag2} </h3>
<h3>或操作: ${flag1 || flag2} 和和和和和 ${flag1 or flag2} </h3>
<h3>非操作: ${!flag1} 和和和和和 ${not flag1} </h3>
<h3>是否为空: ${empty a} </h3>
<h3> 三目运算 ${a>b?"大于":"小于"} </h3>
<h3> 括号运算符 ${c*(a+b)} </h3>