<%-- 用el表示式取資料的時候,通常用.號,如果.號取不出資料,在換用 --%>
--------------------------------------------servlet直接傳資料---------------------------------------------
<%
string date="用來測試el表示式";
request.setattribute("date", date);
%>
$;--------------------------------------------servlet封裝資料在物件中傳送(1)-------------------------------
<%
person person=new person();
person.setname("思想領袖");
request.setattribute("person", person);
%>
第乙個人的名字:$
--------------------------------------------servlet封裝資料在物件中傳送(2)-------------------------------
<%
person person2=new person();
address address=new address();
address.setcity("ningbo");
person2.setaddress(address);
request.setattribute("person2", person2);
%>
list list=new arraylist();
person p1=new person("統治者");
person p2=new person("領袖");
person p3=new person("優秀是一種習慣");
list.add(p1);
list.add(p2);
list.add(p3);
request.setattribute("list", list);
%>
list集合的形式傳送過來的資料: $
--------------------------------------------servlet封裝資料在map中傳送------------------------------------
<%
map map=new hashmap();
map.put("aa", new person("aaa"));
map.put("bb", new person("bbb"));
map.put("cc", new person("ccc"));
map.put("dd", new person("ddd"));
request.setattribute("map", map);
%>
map集合形式傳送過來的資料: $
map,list如果想要逐個的取出其中的資料,那麼就要使用jstl標籤來進行操作,請看jstl配合el表示式的使用
EL表示式使用
el 全名稱為 expression language 它是為了使jsp寫起來更加簡單。表示式語言的靈感來自於 ecmascript 和 xpath 表示式語言,它提供了在 jsp 中簡化表示式的方法,讓jsp的 更加簡化。它語法很簡單,它最大的特點就是使用上很方便。接下來介紹el主要的語法結構 與...
EL表示式使用
empty運算可以判斷出乙個資料是否為空,如果為空,則輸出true,不為空輸出false。一下幾種情況為空 request.setattribute emptynull null request.setattribute emptystr request.setattribute emptyarr ...
EL表示式 EL表示式顯示資料
1.基本資料型別與string型別 request.setattribute scores 滿分 request.setattribute a 1 頁面顯示為 滿分2.自定義型別 a 在頁面中要顯示的自定義類成員變數必須要有getter b 如何顯示 建立乙個student類 request.set...