EL表达式

JSTL简介:SUN的标准Taglib库,和其他jar文件没有任何关联。

JSP标准标签库

容器要求2.4以上

 

表达式语言:EL

${Scope中的对象}

el中的隐含对象(如果未指定scope,则寻找的顺序为)pageScope,requestScope,sessionScope,applicationScope,

//普通字符串

request.getAttribute(“hello”),${hello},${requestScope.hello}

//结构 采用.进行导航,也称存取器

${user.username},${user.group.name},属性必须有getter方法

//Map  EL表达式没有循环,需借助JSTL

${mapValue.key1},${mapValue.key2}

Map mapValue=new HashMap();

mapValue.put(“key1”,”value1”);mapValue.put(“key2”,”value2”)

mapValue

//字符串数组 采用[]和下标 下标从0开始

String[] atrArray=new String[]{“a”,'”b”,'‘”c”}

${atrArray[0]}

//对象数组 采用[]和下标 下标从0开始

User[] users=new User[10];

${users[3].username}

//List  同数组

${userList[2].username}

List userList=new ArrayList();

userList.add(new User());

//el表达式对运算符的支持

${1+2}:页面上输出3

${10/5},${10 div 5}:页面输出2.0

${10 mode 5},${10 % 5}:求余

//测试Empty

${empty value1}:如果value1为空,则为true,否则为发false

原文地址:https://www.cnblogs.com/guaniu/p/2324069.html