JSP, JSTL, Bean Inheritance, and PropertyNotFoundException [duplicate]
-
05-06-2021 - |
Question
I have two JavaBeans.
- User
- Engineer
Engineer extends User.
User contains this property:
public String getName() { return name; }
My JSP contains:
<c:forEach var="engineer" items="${engineers}" >
<c:out value="${engineer.Name}" />
</c:forEach>
The exception being thrown is:
javax.el.PropertyNotFoundException: Property 'Name' not found on type Engineer
Is this because JSTL won't find the inherited properties? Will I need to explicitly declare another getName
property on Engineer even though it inherits getName
from User?
Solution
It should be
${engineer.name}
the name
should be lower case.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow