EL语法中#{...}和$ {...}之间有什么区别 [英] What is the difference between #{...} and ${...} in EL Syntax

查看:331
本文介绍了EL语法中#{...}和$ {...}之间有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题很简单,你可以看到。

My question is straightforward as you can see.

#{...} 和 $ {...}

推荐答案

简单地说, $ {} 只能执行 get ,而#{} 可以获取 设置的值。

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.

  • Difference between JSP EL, JSF EL and Unified EL

这篇关于EL语法中#{...}和$ {...}之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆