java el表达式原理_el表达式实现原理 | 学步园

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

extends PageContext

proprietaryEvaluate

public static java.lang.Object proprietaryEvaluate(java.lang.String expression,

java.lang.Class expectedType,

PageContext pageContext,

ProtectedFunctionMapper functionMap,

boolean escape)

throws ELException

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.

参数:

expression - The expression to be evaluated

expectedType - The expected resulting type

pageContext - The page context

functionMap - Maps prefix and name to Method

返回:

The result of the evaluation

抛出:

ELException

例如:

(java.lang.String)org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param[/"usern/"] }", java.lang.String.class,

(PageContext)_jspx_page_context, null, false)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值