The result of ${...}
is a value, while the result of #{...}
is a binding. This binding can be executed over and over again.
EL distinguishes between two kinds of bindings; a value binding and a method binding. The value binding is just a convenience for a general method binding, as it represents both a getter and setter via a single expression.
In a way, ${...}
can be compared with passing a value into a method via an expression:
foo(bar.kaz());
At runtime, bar.kaz()
is evaluated and foo only receives the value returned. The foo method knows nothing about bar.kaz()
and cannot do the evaluation again at a later time.
#{...}
can be compared a little with passing a lambda into a method, or an old anonymous inner class:
foo(new IntegerReturn() { public int execute() {
bar.kaz();
});
Here, foo gets an IntegerReturn
that it can invoke as much as it wants at the time it wants.