EL 语法中#{...} 和 ${...} 有什么区别 [英] What is the difference between #{...} and ${...} in EL Syntax
问题描述
如您所见,我的问题很简单.
My question is straightforward as you can see.
EL 语法中的 #{...}
和 ${...}
有什么区别?
What is the difference between #{...}
and ${...}
in EL Syntax?
推荐答案
简单地说,${}
只能做一个 get
,而 #{}
可以对值执行 get
和 set
.
Simply put, the ${}
can do only a get
, while the #{}
can do a get
and a set
of the value.
在旧版 JSP 上的 JSF 中,#{}
语法是必需的,以触发托管 bean 的自动创建并将请求参数设置为模型值.如果您在 JSF 页面中使用了 ${bean.value}
,那么名为 bean
的托管 bean 将不会被自动创建,如果它不在范围.此外,如果表单是在输入组件中使用该值提交的,则不会设置托管 bean 属性 value
.
In JSF on legacy JSP, the #{}
syntax is mandatory to trigger auto-creation of managed beans and to set request parameters as model values. If you used ${bean.value}
in a JSF page, then the managed bean with name bean
won't be auto-created if it isn't already in the scope. Also, the managed bean property value
won't be set if the form was submitted with that value in an input component.
在 Facelets 上的 JSF 中,${}
被重新解释为 #{}
,因此它们的行为将完全相同.
In JSF on Facelets, the ${}
is reinterpreted as #{}
and thus they will behave exactly the same.
这篇关于EL 语法中#{...} 和 ${...} 有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!