What are the differences between ${} and #{}?

Filippo1980 picture Filippo1980 · Jan 9, 2012 · Viewed 31.6k times · Source

I'm programming in JSF2 and NetBeans creates many pages with #{} that contains an expression. However sometimes on the web I found ${} for the same thing!

Are there any differences? What are they?

Answer

Fortunato picture Fortunato · Jan 9, 2012
  • #{} are for deferred expressions (they are resolved depending on the life cycle of the page) and can be used to read or write from or to a bean or to make a method call.
  • ${} are expressions for immediate resolution, as soon as they are encountered they are resolved. They are read-only.

You can read more here: http://docs.oracle.com/javaee/6/tutorial/doc/bnahr.html