On the JSP page, I am doing like this ${records.size}
where records is of Set
type. Then I am getting this error.
I check the documentation and size()
method is available in org.hibernate.collection.internal.PersistentSet
.
So what could be possible reason for this error?
The syntax ${records.size}
basically tells EL to print the size
property (not method!) of the bean as identified by ${records}
. When EL needs to obtain a property, then it will look up the getter method in the class behind the bean. So when the property name is size
then the expected getter method is getSize()
. If this method is absent, then you will face exactly the exception you're currently facing. See also javax.el.PropertyNotFoundException: Property 'foo' not found on type com.example.Bean.
And indeed, the org.hibernate.collection.internal.PersistentSet
does not have the getSize()
method. I.e. it does indeed not have the size
property at all. So the exception is completely right.
Basically you want to invoke the size()
method instead, not the getter method behind the size
property. Fix your EL expression accordingly:
${records.size()}