《EL表达式显示输出.doc》由会员分享,可在线阅读,更多相关《EL表达式显示输出.doc(7页珍藏版)》请在金锄头文库上搜索。
1、1.普通字符串request.setAttribute(hello, hello world);-El表达式获取普通字符串hello(jsp脚本):hello(el表达式,el表达式的使用方法$和):$hello hello(el表达式,el的隐含对象pageScope,requestScope,sessionScope,applicationScope, 如果未指定scope,它的搜索顺序pageScopeapplicationScope):$requestScope.hello hello(el表达式,scope=session):$sessionScope.hello -页面输出.普通字
2、符串hello(jsp脚本):hello worldhello(el表达式,el表达式的使用方法$和):hello worldhello(el表达式,el的隐含对象pageScope,requestScope,sessionScope,applicationScope,如果未指定scope,它的搜索顺序为pageScopeapplicationScope):hello worldhello(el表达式,scope=session):2.结构Group group = new Group();group.setName(尚学堂);User user = new User(); user.setU
3、sername(张三); user.setAge(18); user.setGroup(group); request.setAttribute(user, user);-El表达式获取结构,采用.进行导航,也称存取器姓名:$user.username 年龄:$user.age 所属组:$user.group.name -页面输出.结构,采用.进行导航,也称存取器姓名:张三年龄:18所属组:尚学堂3.mapMap mapValue = new HashMap(); mapValue.put(key1, value1); mapValue.put(key2, value2);request.se
4、tAttribute(mapvalue, mapValue);-El表达式获取输出map,采用.进行导航,也称存取器mapvalue.key1:$mapvalue.key1 mapvalue.key2:$mapvalue.key2 -页面输出.输出map,采用.进行导航,也称存取器mapvalue.key1:value1mapvalue.key2:value24.字符串数组String strArray = new Stringa, b, c;request.setAttribute(strarray, strArray);User users = new User10; for (int i
5、=0; i10; i+) User u = new User(); u.setUsername(U_ + i); usersi = u; request.setAttribute(users, users);-El表达式获取输出对象数组,采用和下标userarray3.username:$users2.username -页面输出.输出对象数组,采用和下标userarray3.username:U_25.ArrayListList userList = new ArrayList(); for (int i=0; i10; i+) User uu = new User(); uu.setUse
6、rname(UU_ + i); userList.add(uu); request.setAttribute(userlist, userList);-El表达式获取输出list,采用和下标userlist5.username:$userlist4.username -页面输出输出list,采用和下标userlist5.username:UU_46.emptyrequest.setAttribute(value1, null);request.setAttribute(value2, );request.setAttribute(value3, new ArrayList();request.
7、setAttribute(value4, 123456);-El表达式获取el表达式对运算符的支持 1+2=$1+2 10/5=$10/5 10 div 5=$10 div 5 10%3=$10 % 3 10 mod 3=$10 mod 3 !- =/eq !=/ne /gt=/ge&/and|/or!/not/div%/mod- 测试empty value1:$empty value1 value2:$empty value2 value3:$empty value3 value4:$empty value4 value4:$!empty value4 -页面输出.el表达式对运算符的支持1
8、+2=310/5=2.010 div 5=2.010%3=110 mod 3=1.测试emptyvalue1:truevalue2:truevalue3:truevalue4:falsevalue4:true普通字符串request.setAttribute(hello, hello world);-El表达式获取普通字符串hello(jsp脚本):hello(el表达式,el表达式的使用方法$和):$hello hello(el表达式,el的隐含对象pageScope,requestScope,sessionScope,applicationScope, 如果未指定scope,它的搜索顺序p
9、ageScopeapplicationScope):$requestScope.hello hello(el表达式,scope=session):$sessionScope.hello -页面输出.普通字符串hello(jsp脚本):hello worldhello(el表达式,el表达式的使用方法$和):hello worldhello(el表达式,el的隐含对象pageScope,requestScope,sessionScope,applicationScope,如果未指定scope,它的搜索顺序为pageScopeapplicationScope):hello worldhello(e
10、l表达式,scope=session):2.结构Group group = new Group();group.setName(尚学堂);User user = new User(); user.setUsername(张三); user.setAge(18); user.setGroup(group); request.setAttribute(user, user);-El表达式获取结构,采用.进行导航,也称存取器姓名:$user.username 年龄:$user.age 所属组:$user.group.name -页面输出.结构,采用.进行导航,也称存取器姓名:张三年龄:18所属组:尚学堂3.mapMap mapValue = new HashMap(); mapValue.put(key1, value1); mapValue.put(key2, value2);request.setAttribute