Whats the difference between “${foo.bar}” and “#{foo.bar}”?

前端 未结 2 804
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-14 00:55

I can use objects from my Java Beans within .jsp files by using the Expression Language (EL). Therefore I can get my value by typing ${foo.bar}. But I can also use #{foo.bar

2条回答
  •  误落风尘
    2021-01-14 01:29

    This is covered in the JSP 2.1 spec.

    In Java EE, #{expr} is used for deferred evaluation and ${expr} for immediate evaluation. Deferred expressions (#{expr}) expressions can only be used with tag attributes that accept them. This is a Java EE convention, but other domains could impose their own meaning (e.g. if you wanted to use EL in your own templates).

提交回复
热议问题