Java – propertynotfoundexception when using JSTL with Boolean value
•
Java
I have a filebean that renames Boolean variables It has the following code
public class FileBean { private boolean renamed; public boolean isRenamed() { return renamed; } public void setRenamed(boolean isRenamed) { this.renamed = isRenamed; } }
I have passed its object to JSP using the request object (consider filedetail is the name of the request attribute) My JSP contains the following code
<tr> <td>${fileDetail.isRenamed}</td> </tr>
Using this, I get lower than runtime exceptions on JSP
org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: Property 'isRenamed' not found on type <mypackage>.FileBean org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Please suggest a solution
Thank you in advance
Solution
You need to use the attribute name / field name If it is a boolean type, JSTL looks for isrenamed () based on the POJO convention
Example:
<td>${fileDetail.renamed}</td>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码