I am getting an error in JSP and I cannot figure out what is causing it. I have included all of the appropriate libraries and I've made sure to follow bean convention on uppercase/lowercase. Here's the relevant code in the JSP:
<c:forEach items="${relevantData}" var="entry">
<p>${entry.price}</p>
</c:forEach>
The relevantData
was a List<MyData>
. For the purposes of this question it is sufficent to say MyData
is a class that contains a Double
named price (with a Getter and Setter following the bean convention). When I try to load this page I receive the following error in the server logs (Tomcat 7.0.22):
javax.el.PropertyNotFoundException:
Property 'price' not readable on type java.lang.Double
Why am I getting this error and how do I fix it?
The problem was actually caused by the visibility of the MyData
class. I had auto-generated the MyData
class in Netbeans but I did not notice that there was no keyword public
in front of the class name. This meant that by the time it got to the JSP there was no way for it to read the properties in MyData
.
I changed the type to public
and the problem was solved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With