Express Language: replace the function of <%= ..... %> in JSP.
The grammar of EL: ${ EL content }:
<%= 1+1 %> equals ${ 1+1 }
Where to get the data via EL?
pageContext, request, session, application the four important domain object.
The following is a JavaBean class:
class Person{ private String name = "pp"; private String city; getter/setter; }
To get the Person class's name String in the JSP:
<% Person p = new Person(); pageContext.setAttribute("p",p); %> name: ${p.name} <%-- the "." means call the getter method fo Person class --%>
name: ${p["name"]} <%-- has the same function --%>
Get the data in List:
<% List<String> list = new ArrayList<String>(); list.add("aaa"); list.add("bbb"); list.add("ccc"); pageContext.setAttribute("list", list); %> List:${list[1] }
Get the data in Map:
<% Map<String,String> map = new HashMap<String,String>(); map.put("a", "aaa"); map.put("b", "bbb"); map.put("c", "ccc"); pageContext.setAttribute("map", map); %>
Map:${map.a }
.