限制條件
只能訪問域對象的數據
用法
訪問基本數據類型
首先把數據保存在域對象中
pagecontext.setAttribute("name","eric");
取處對象
${name}
訪問引用數據類型
輸出對象的屬性值
class Student{
private String name;
private String id ;
public String getName(){
return this.name;
}
public String getId(){
return this.id;
}
}
在jsp頁面中執行以下代碼
Student student = new Studet();//創建對象
pagecontext.setAttribute("student","student");//保存到域對象中
${student.name} --${student.id} //點 代表的是get然后把name首字母大寫(調用方法)等價於((Student)pagecontext.findAttribute("student").getName())
輸出集合對象
list集合
List list = new ArrayList();
list.add(new Strdent("張三","001"));
${list[0].name}-${list[0].id}
中括號相當於調用getxxx方法本例相當於pagecontext.findAttribute("list").get(0);
map集合
Map map = new TreeMap();
map.put("1000",new Strdent("張三","001"));
pagecontext.setAttribute("map",map);
${map['1000'].name}-${map['1000'].id};
傳入一個key值
進行算術和比較運算${寫入表達式}
判空的時候也可以用${empty 值}等價於${值==null}