el運算式實現原理

來源:互聯網
上載者:User
jstl標籤中的el

在路徑org.apache.taglibs.standard.lang.support下,有個叫 ExpressionEvaluatorManager.evaluate 的方法,當el運算式作為入參時,調用這個方法,在tag內即可自動把el運算式轉化。

 

ExpressionEvaluatorManager.evaluate有四個參數。第一個表示tag的名字,在取el運算式出錯時使用。一般和屬性名稱
字相同。第二個要求字串,通常簡單調用輸入對象的toString方法。第三個是類,通常用Object.class。第四個用this即可,第五個是
pageContext變數。

 

頁面中的el

在org.apache.jasper.runtime包中,有一個類用來實現PageContext並且解析EL.

 

public class PageContextImpl<br />extends PageContext</p><p>proprietaryEvaluate<br />public static java.lang.Object proprietaryEvaluate(java.lang.String expression,<br /> java.lang.Class expectedType,<br /> PageContext pageContext,<br /> ProtectedFunctionMapper functionMap,<br /> boolean escape)<br /> throws ELException<br /> Proprietary method to evaluate EL expressions. XXX - This method should go away once the EL interpreter moves out of JSTL and into its own project. For now, this is necessary because the standard machinery is too slow.<br /> 參數:<br /> expression - The expression to be evaluated<br /> expectedType - The expected resulting type<br /> pageContext - The page context<br /> functionMap - Maps prefix and name to Method<br /> 返回:<br /> The result of the evaluation<br /> 拋出:<br /> ELException<br />

 

例如:

(java.lang.String)org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param[/"usern/"] }", java.lang.String.class,<br />(PageContext)_jspx_page_context, null, false)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.