I have a variable declared as type Object a
which actually refers an instance of type A
.
In EL, I can directly use the following expression to print the name
property of type A
:
${a.name}
How does it work?
I have a variable declared as type Object a
which actually refers an instance of type A
.
In EL, I can directly use the following expression to print the name
property of type A
:
${a.name}
How does it work?
It's because
name
is a property of the objecta
, and probably the object is also a JavaBean (not to be confused with Enterprise JavaBean).See here for Expression Language Documentation and here for a short tutorial.
EL uses reflection under the hoods, usually via
javax.beans.Introspector
API.This is what it roughly does under the covers on
${a.name}
.It does not convert/cast the type in any way.
See also: