運算式語言(EL運算式)

來源:互聯網
上載者:User

運算式語言的特點:
 *可獲得的名稱空間(PageContext屬性)
 *嵌套的屬性,可以訪問集合對象
 *可以執行關係的、邏輯的和算術的運算
 *擴充函數可以和Java類的靜態方法映射
 *它可以訪問JSP的一系列的隱含對象(request、session、application、page等)
 
 輸出${字元:
 ${'${'}true;
 <%@ page isELIgnored="true|false"%>
 PageContext.findAttribute(String name)來尋找運算式對應的變數
 
 運算式語言定義了一些隱含對象
 *pageContext
 *param
 *paramValues
 *header
 *headerValues
 *cookie
 *initParam
 *pageScope
 *requestScope
 *sessionScope
 *applicationScope
 
 
 ${departments[deptName] }Map中的deptName的屬性值
 
 
 
 定義的函數必須是靜態static
 tld格式:
  <function>
   <name>add</name>
   <function-class>com.yao.Function</function-class>
   <function-signature>int add(int, int)</function-signature>
  </function>
 
  <function>
   <name>trans</name>
   <function-class>com.yao.Function</function-class>
   <function-signature>java.lang.String trans(java.lang.String)</function-signature>
  </function>
 
  web.xml格式(“/”相對於WebRoot):
  <jsp-config>
   <taglib>
    <taglib-uri>http://yao.com/jsp/function</taglib-uri>
    <taglib-location>/functions.tld</taglib-location>
   </taglib>
  </jsp-config>
 
  jsp頁面調用:
  ${myfun:trans(param.name)};
  ${myfun:add(param["x"],param["y"])};
 
   重中之重:${對象}
 
 <hr>一種使用獲得參數的方法:<br>
 姓名:${user.userName}<br>
 密碼:${user.password}<br>
 年齡:${user.age}<br>
 <hr>
 <hr>另一種使用獲得參數的方法:<br>
 姓名:${param.userName}<br>
 密碼:${param.password}<br>
 年齡:${param.age}<br>
 <hr>又一種使用獲得參數的方法:<br>
 姓名:${param['userName']}<br>
 密碼:${param['password']}<br>
 年齡:${param['age']}<br>
 <hr>再一種使用獲得參數的方法:<br>
 姓名:${param["userName"]}<br>
 密碼:${param["password"]}<br>
 年齡:${param["age"]}<br>
 <hr>最後一種使用獲得參數的方法:<br>
 姓名:${requestScope.user.userName}<br>
 密碼:${requestScope.user.password}<br>
 年齡:${requestScope.user.age}<br>
 
 --------------------------------------------------------------------------------
 一種使用獲得參數的方法:
 姓名:12
 密碼:12
 年齡:101
 
 --------------------------------------------------------------------------------
 
 --------------------------------------------------------------------------------
 另一種使用獲得參數的方法:
 姓名:12
 密碼:12
 年齡:1
 
 --------------------------------------------------------------------------------
 又一種使用獲得參數的方法:
 姓名:12
 密碼:12
 年齡:1
 
 --------------------------------------------------------------------------------
 再一種使用獲得參數的方法:
 姓名:12
 密碼:12
 年齡:1
 
 --------------------------------------------------------------------------------
 最後一種使用獲得參數的方法:
 姓名:12
 密碼:12
 年齡:201
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.