1.普通字符串request.setAttribute("hello", "hello world");---------------------------------------------El表达式获取
普通字符串hello(jsp脚本):<%=request.getAttribute("hello") %>
hello(el表达式,el表达式的使用方法$和{}):${hello }
hello(el表达式,el的隐含对象pageScope,requestScope,sessionScope,applicationScope,
如果未指定scope,它的搜索顺序pageScope~applicationScope):${requestScope.hello }
hello(el表达式,scope=session):${sessionScope.hello }
--------------------------------------------页面输出.普通字符串hello(jsp脚本):hello worldhello(el表达式,el表达式的使用方法$和{}):hello worldhello(el表达式,el的隐含对象pageScope,requestScope,sessionScope,applicationScope,如果未指定scope,它的搜索顺序为pageScope~applicationScope):hello worldhello(el表达式,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("mapvalue", mapValue);---------------------------------------------El表达式获取
输出map,采用.进行导航,也称存取器mapvalue.key1:${mapvalue.key1 }
mapvalue.key2:${mapvalue.key2 }
--------------------------------------------页面输出.输出map,采用.进行导航,也称存取器mapvalue.key1:value1mapvalue.key2:value2<><><><><><><><><><><><><><><><><><><>4.字符串数组String[] strArray = new String[]{"a", "b", "c"};request.setAttribute("strarray", strArray);User[] users = new User[10]; for (int i=0; i<10; i++) { User u = new User(); u.setUsername("U_" + i); users[i] = u; }request.setAttribute("users", users);---------------------------------------------El表达式获取
输出对象数组,采用[]和下标userarray[3].username:${users[2].username }
--------------------------------------------页面输出.输出对象数组,采用[]和下标userarray[3].username:U_2<><><><><><><><><><><><><><><><><><><>5.ArrayListList userList = new ArrayList(); for (int i=0; i<10; i++) { User uu = new User(); uu.setUsername("UU_" + i); userList.add(uu); }request.setAttribute("userlist", userList);---------------------------------------------El表达式获取
输出list,采用[]和下标userlist[5].username:${userlist[4].username }
--------------------------------------------页面输出输出list,采用[]和下标userlist[5].username:UU_4<><><><><><><><><><><><><><><><><><><>6.emptyrequest.setAttribute("value1", null);request.setAttribute("value2", "");request.setAttribute("value3", new ArrayList());request.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 }
测试empty value1:${empty value1 }
value2:${empty value2 }
value3:${empty value3 }
value4:${empty value4 }
value4:${!empty value4 }
--------------------------------------------页面输出.el表达式对运算符的支持1+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脚本):<%=request.getAttribute("hello") %>
hello(el表达式,el表达式的使用方法$和{}):${hello }
hello(el表达式,el的隐含对象pageScope,requestScope,sessionScope,applicationScope,
如果未指定scope,它的搜索顺序pageScope~applicationScope):${requestScope.hello }
hello(el表达式,scope=session):${sessionScope.hello }
--------------------------------------------页面输出.普通字符串hello(jsp脚本):hello worldhello(el表达式,el表达式的使用方法$和{}):hello worldhello(el表达式,el的隐含对象pageScope,requestScope,sessionScope,applicationScope,如果未指定scope,它的搜索顺序为pageScope~applicationScope):hello worldhello(el表达式,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("mapvalue", mapValue);---------------------------------------------El表达式获取
输出map,采用.进行导航,也称存取器mapvalue.key1:${mapvalue.key1 }
mapvalue.key2:${mapvalue.key2 }
--------------------------------------------页面输出.输出map,采用.进行导航,也称存取器mapvalue.key1:value1mapvalue.key2:value2<><><><><><><><><><><><><><><><><><><>4.字符串数组String[] strArray = new String[]{"a", "b", "c"};request.setAttribute("strarray", strArray);User[] users = new User[10]; for (int i=0; i<10; i++) { User u = new User(); u.setUsername("U_" + i); users[i] = u; }request.setAttribute("users", users);---------------------------------------------El表达式获取
输出对象数组,采用[]和下标userarray[3].username:${users[2].username }
--------------------------------------------页面输出.输出对象数组,采用[]和下标userarray[3].username:U_2<><><><><><><><><><><><><><><><><><><>5.ArrayListList userList = new ArrayList(); for (int i=0; i<10; i++) { User uu = new User(); uu.setUsername("UU_" + i); userList.add(uu); }request.setAttribute("userlist", userList);---------------------------------------------El表达式获取
输出list,采用[]和下标userlist[5].username:${userlist[4].username }
--------------------------------------------页面输出输出list,采用[]和下标userlist[5].username:UU_4<><><><><><><><><><><><><><><><><><><>6.emptyrequest.setAttribute("value1", null);request.setAttribute("value2", "");request.setAttribute("value3", new ArrayList());request.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 }
测试empty value1:${empty value1 }
value2:${empty value2 }
value3:${empty value3 }
value4:${empty value4 }
value4:${!empty value4 }
--------------------------------------------页面输出.el表达式对运算符的支持1+2=310/5=2.010 div 5=2.010%3=110 mod 3=1.测试emptyvalue1:truevalue2:truevalue3:truevalue4:falsevalue4:true。