EL表示式和
阿新 • • 發佈:2018-12-11
EL表示式
EL表示式用於獲取資料,在JSP頁面中可使用${識別符號}的形式通知JSP引擎呼叫pageContext.findAttribute()方法,以識別符號為關鍵字從各個域物件中獲取物件。如果域物件中不存在識別符號所對應的物件,則返回結果為””(注意,不是null)。
<body> <% Address address = new Address(); address.setLocation("廣州"); address.setZipcode("020123"); Student s = new Student(); s.setName("小華"); s.setAge(20); s.setSalary(3500); s.setAddress(address); session.setAttribute("S",s); %> 使用者名稱:${S.name}<br/> 年齡:${S.age}<br/> 薪水:${S.salary}<br/> 地址:${S.address.location}<br/> 郵編:${S.address.zipcode}<br/> <hr/> 10>5->${10>5} 10==5->${10==5} 10<5->${10<5} </body>