EL Operators
Introduction:
Expression Language (EL) contains its own set of operators the following is the list of all available operators in Expression Language (EL) .
1. Property access operator: (.)
2. Collection access operator : ([])
3. Arithmetic Operators
4. Relational Operators
5. Logical Operators.
1. Property Access Operator: (.)
Syntax:
Ex- ${param.uname}
Map key
Ex: ${initParam.password}
Map key
Ex: ${customer.age}
Bean property
1. Collection Access Operator : []
Syntax: ${LeftVariable [RightVariable]}
LeftVariable : Map , Bean ,Array, List
RightVariable : Key,Property,index
Example for map:
· $ {initParam[“mail”]}
Example for Bean:
· $ {customer [“name”]}
Example for Arrays:
<%@ page isELIgnored="false" %> <%@ page import="java.util.*" %> <% String[ ] s = {"myjavahub", "java2s", "javaken", "java2share" }; pageContext.setAttribute ("s", s); %> ${s[0]}<br> ${s[1]}<br> ${s[2]}<br> ${s[3]}<br> ${s[100]} |
Example for List:
<%@ page isELIgnored="false" %> <%@ page import="java.util.*" %> <% List<String> l = new ArrayList<String>(); l.add("myjavahub"); l.add("java2s"); l.add("javaken"); l.add("java2share"); pageContext.setAttribute ("List",l); %> ${List["0"]}<br> ${List["1"]}<br> ${List["2"]}<br> ${List["3"]}<br> |
No comments:
Post a Comment