el表达式 取到指定的值
<td><input type="text" name="001" id="001" value="${request.listdata[1]}"/></td>
对listdata取到它的第二个值
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%><%@page import="com.vo.Files"%>
<html>
<head>
<title>EL表达式的使用</title>
</head>
<body>
<!-- El的书写的格式-->
<h2>基本运算符</h2>
简单的算数的运算:<br>
\${1+1} = ${1+1} = <%=1+1 %><br>
\${(1+1)*(2+2) } = ${(1+1)*(2+2) }<br>
逻辑的运算<br>
\${true } =${true }<br>
\${not true } =${ not true } =${!true }<br>
\${ true and false } =${ true and false }=${ true && false } <br>
\${ true or false } =${ true or false } = ${ true || false }<br>
比较运算符<br>
\${ 3 > 5 } = ${3 > 5 } = ${3 gt 5 }<br>
\${3==5 } = ${3==5 } = ${3 eq 5 } <br>
\${3>=5 } = ${3>=5 } = ${3 ge 5 } <br>
\${3!=5 } = ${3!=5 } = ${ not (3 eq 5) } <br>
<h2> ( . [] )运算符:索引运算符,配合从内置对象中获取信息</h2>
<%
//request.setAttribute("test","测试的数据1");
session.setAttribute("test","测试的数据2");
//pageContext.setAttribute("test","测试的数据3");
application.setAttribute("test","测试的数据4");
%>
<h3>request.setAttribute("test","测试的数据")</h3><br>
\${requestScope.test} : ${requestScope.test} <br>
\${sessionScope.test} : ${sessionScope.test} <br>
\${pageContextScope.test} : ${pageScope.test} <br>
\${applicationScope.test} : ${applicationScope.test} <br>
简化的书写: \${test } 查询属性从page->request->session->applcation<br>
<%
ArrayList<String> list=new ArrayList<String>();
list.add("Hello");
list.add("World");
list.add("!");
session.setAttribute("list",list);
//list的操作等同于array[]数组的操作
Map<String,String> map=new HashMap<String,String>();
map.put(""+1,"所得税1");
map.put(""+2,"所得税2");
map.put(""+3,"所得税3");
request.setAttribute("map",map);
//注意map集合的key一般使用String类型 作为key的取值
%>
\${sessionScope.list[数据的索引index] } = ${sessionScope.list[2] }<br> sessionScope是指定的范围 例如request session 。。。
\${requestScope.map['2'] }=${requestScope.map["2"] } <br> 同样requestScope是指定的范围
<%
Files f=new Files();
f.setRealfile("哈哈哈哈");
request.setAttribute("f",f);
%>
<br>
\${requestScope.f.realfile }=${requestScope.f.realfile }
<!--
创建5个对象 对象的名字 u1..u5
先将对象存放在一个Arraylist的链表中ulist
将链表放在request中 做属性 名字是 list
问:显示低个人的名字
-->
</body>
</html>
浙公网安备 33010602011771号