JSP EL、JSF EL 和 Unified EL 之间的区别
我想知道表达式语言(EL)之间的详细区别。 有 JSP EL、JSF EL 和 Unified EL。
我想了解 EL 背后的历史以及 Java EE 应用程序中使用的最新 EL 是什么。它是最新版本中所有视图技术通用的 EL 吗?
I would like to know the detailed difference between the Expression Languages (EL).
There is JSP EL, JSF EL and Unified EL.
I would like to know the history behind the EL and what the latest EL is that is used in Java EE applications. Is it the EL common for all view technologies in the latest versions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
2002 年 6 月:JSTL 1.0 首次与 EL 一起引入。这些
${}
内容仅适用于 JSTL 标记。它旨在调用 Javabeanget
方法。2003 年 11 月:引入了 JSP 2.0,并且 EL 在
javax.servlet.jsp.el
包,它成为标准 EL 作为 J2EE 1.4 标准的一部分。 JSTL 1.1 出厂时没有 EL。现在,${}
也可以在 JSP 模板文本中的 JSTL 标记之外工作。2004 年 3 月:JSF 1.0 与 延迟 EL 一起在
javax.faces.el
包。这些#{}
内容仅在 JSF 标记内起作用。与标准 JSP EL${}
的区别在于,它不仅可以执行get
操作,还可以执行set
操作。这对于托管 bean 自动创建和设置输入组件的值是必需的。标准 EL${}
也适用于 JSF 输出标记,但如果它们不存在于范围内,它们不会自动创建 bean,并且不会设置输入值。2005 年 5 月:在为 2006 年 5 月发布的新 JSP 2.1 做准备的同时,从 JSF 中提取了延迟的 EL
#{}
并与标准 EL${}
相结合> 在javax.el
包。那时,它成为随 JSF 1.2 引入的统一 EL,并成为后来的 JSP 2.1 和 Java EE 5 标准的一部分。#{}
现在也可以在 JSP 标记中使用来获取
值,但不能设置
值。${}
现在还可以在 JSP 中自动创建托管 bean,但不能set
值。2006 年 11 月:Facelets 作为 JSP 的继承者推出。它允许在 JSF 标记之外的模板文本中使用
#{}
,作为不带任何属性的
的替代。它还将${}
视为#{}
,因此它们在 Facelets 中的行为相同。2009年12月:EL从JSP规范中提取出来,成为一个独立的规范,将独立于JSP进行维护,第一个版本是EL 2.2(JSR-245),类似于JSP 2.2。主要的新功能是调用参数化方法,而不是仅在
#{}
语法中调用 Javabean getter/setter,例如#{bean.method(argument)}
。此外,Facelets 成为 Java EE 6 标准的一部分。2013 年 6 月:引入了 EL 3.0,它配备了独立的 EL 处理器,允许在普通 Java SE 应用程序中使用。其他主要新功能包括新的字符串连接运算符
+=
、集合对象的新操作,包括流和 Lambda 表达式->
(甚至在 Java 6/7 上!)并将常量导入 EL 作用域。Jun 2002: JSTL 1.0 was introduced with EL for first time. It were those
${}
things which works in JSTL tags only. It is designed to call Javabeanget
methods.Nov 2003: JSP 2.0 was introduced and EL was moved from JSTL 1.0 to JSP 2.0 in
javax.servlet.jsp.el
package and it became standard EL as part of J2EE 1.4 standard. JSTL 1.1 was shipped without EL. Now${}
works outside JSTL tags in JSP template text as well.Mar 2004: JSF 1.0 was introduced with deferred EL in
javax.faces.el
package. It were those#{}
things which works inside JSF tags only. The difference with standard JSP EL${}
is that it doesn't only doget
, but can also doset
. This was mandatory for managed bean auto-creation and setting the values of input components. The standard EL${}
works in JSF output tags as well, but they won't auto-create beans if they don't exist in scope yet and they won't set input values.May 2005: While still preparing for new JSP 2.1 which should be released May 2006, deferred EL
#{}
was extracted from JSF and combined with standard EL${}
in thejavax.el
package. At that point, it became unified EL which was introduced with JSF 1.2 and became later part of JSP 2.1 and Java EE 5 standard. The#{}
can now also be used in JSP tags toget
values, but not toset
values. The${}
can now in JSP also auto-create managed beans, but notset
values.Nov 2006: Facelets was introduced as successor of JSP. It allowed for use of
#{}
in template text outside JSF tags, as substitute for<h:outputText>
without any attributes. It also treats${}
as#{}
, so they both behave the same in Facelets.Dec 2009: EL was extracted from JSP specification and became a standalone specification which will be maintained independently from JSP, the first version being EL 2.2 (JSR-245), analogous with JSP 2.2. Main new feature is calling parameterized methods instead of only calling Javabean getters/setters inside
#{}
syntax, e.g.#{bean.method(argument)}
. Furthermore, Facelets became part of Java EE 6 standard.Jun 2013: EL 3.0 was introduced which comes with a standalone EL processor, allowing usage in a plain Java SE application. Other main new features are the new string concatenation operator
+=
, new operations for collection objects, including streams and Lambda expressions->
(even on Java 6/7!) and importing constants into EL scope.添加到 BalusC 的答案...
EL 最初是由 Art Technology Group 的 Nathan Abramson 于 2001 年构思并实现的。当时,该实现被称为最简单可能的表达语言 (SPEL)。该实现后来被包含在 JSTL1.0 中。 Nathan 是 JSR-052 专家组 的成员,并被授予JSTL 规范 作为表达语言背后的驱动力。
Adding to BalusC's answer...
EL was originally conceived by and implemented by Nathan Abramson of Art Technology Group in 2001. At the time the implementation was known as Simplest Possible Expression Language (SPEL). The implementation was later included in the JSTL1.0. Nathan was part of the JSR-052 Expert Group, and was credited in the JSTL specification as the driving force behind the expression language.