You seem to be mixing JSF with EL. Those things ${}
and #{}
is EL. EL is not part of JSF. EL is a standalone API which happens to be used by both JSF and Spring. JSF and Spring are both capable of placing managed bean instances in EL scope in such way that EL can find and invoke it.
When you do #{foo}
, then EL will pass literal "foo" through a chain of registered EL resolvers. If one of them can find the object instance associated with literal "foo", then it would be returned. There are default resolvers which look for the bean instance associated with request/session/application attribute name e.g. request.getAttribute("foo")
. JSF makes use of those builtin resolvers. JSF basically does request.setAttribute("foo")
under the covers so that EL can find it.
Spring does it a bit differently (like Java EE's own CDI) and therefore needs a custom EL resolver which has basically a register of all registered Spring beans. When Spring's EL resolver is hit, then Spring will look for the bean associated with the literal "foo" in its own register which is filled during webapp's startup based on @Component
. If Spring can't find anything in its register matching "foo", then it will just pass through to the next EL resolver in the chain.
See also: