首先贴出报错信息:
十二月 14, 2017 10:54:42 下午 org.apache.catalina.core.ApplicationDispatcher invoke SEVERE: Servlet.service() for servlet jsp threw exception javax.el.PropertyNotFoundException: Property ‘classroomid‘ not found on type cn.toohoo.classroom.dto.Classroom at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:237) at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:214) at javax.el.BeanELResolver.property(BeanELResolver.java:325) at javax.el.BeanELResolver.getValue(BeanELResolver.java:85) at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:104) at org.apache.el.parser.AstValue.getValue(AstValue.java:183) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185) at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:1026) at org.apache.jsp.admin.classroom.listclassroom_jsp._jspx_meth_c_005fforEach_005f0(listclassroom_jsp.java:356) at org.apache.jsp.admin.classroom.listclassroom_jsp._jspx_meth_c_005fif_005f0(listclassroom_jsp.java:314) at org.apache.jsp.admin.classroom.listclassroom_jsp._jspService(listclassroom_jsp.java:218) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339) at cn.toohoo.classroom.servlet.ClassroomServlet.listClassroom(ClassroomServlet.java:194) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at cn.toohoo.baseservlet.BaseServlet.service(BaseServlet.java:44) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at cn.toohoo.baseservlet.BaseServlet.service(BaseServlet.java:44) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Caused by: org.apache.jasper.JasperException: An exception occurred processing JSP page /admin/classroom/listclassroom.jsp at line 131 128: <c:forEach var="Classroom" items="${requestScope.pageBean.pageData}" varStatus="vs"> 129: <tr> 130: <td>${vs.count }</td> 131: <td>${Classroom.classroomid }</td> 132: <td>${Classroom.classroomname }</td> 133: <td>${Classroom.classroomtype }</td> 134: <td>${Classroom.classroomcapacity }</td> Stacktrace: at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339) at cn.toohoo.classroom.servlet.ClassroomServlet.listClassroom(ClassroomServlet.java:194) ... 22 more Caused by: javax.el.PropertyNotFoundException: Property ‘classroomid‘ not found on type cn.toohoo.classroom.dto.Classroom at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:237) at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:214) at javax.el.BeanELResolver.property(BeanELResolver.java:325) at javax.el.BeanELResolver.getValue(BeanELResolver.java:85) at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:104) at org.apache.el.parser.AstValue.getValue(AstValue.java:183) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185) at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:1026) at org.apache.jsp.admin.classroom.listclassroom_jsp._jspx_meth_c_005fforEach_005f0(listclassroom_jsp.java:356) at org.apache.jsp.admin.classroom.listclassroom_jsp._jspx_meth_c_005fif_005f0(listclassroom_jsp.java:314) at org.apache.jsp.admin.classroom.listclassroom_jsp._jspService(listclassroom_jsp.java:218) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) ... 32 more
然后按照报错信息
javax.el.PropertyNotFoundException: Property ‘classroomid‘ not found on type cn.toohoo.classroom.dto.Classroom
到Classroom实体类查找
private String classroomid; private String classroomname; private String classroomtype; private String classroomcapacity; public String getClassroomId() { return classroomid; } public void setClassroomId(String classroomid) { this.classroomid = classroomid; } public String getClassroomname() { return classroomname; } public void setClassroomname(String classroomname) { this.classroomname = classroomname; }
是存在 private String classroomid; 的呀,然后纳闷,然后各种修改,
。。。。。。。。。。。。。。。
最后,回到jsp
<c:if test="${not empty requestScope.pageBean.pageData}"> <c:forEach var="Classroom" items="${requestScope.pageBean.pageData}" varStatus="vs"> <tr> <td>${vs.count }</td> <td>${Classroom.classroomid }</td> <td>${Classroom.classroomname }</td> <td>${Classroom.classroomtype }</td> <td>${Classroom.classroomcapacity }</td> <td> <a href="<c:url value=‘/ClassroomServlet?method=queryClassroom&classroomid=${Classroom.classroomid }‘/>">修改</a> <a href="<c:url value=‘/ClassroomServlet?method=deleteClassroom&classroomid=${Classroom.classroomid }‘/>">删除</a> </td> </tr> </c:forEach> </c:if>
索性将含有${Classroom.classroomid }的行去掉
改成
<c:if test="${not empty requestScope.pageBean.pageData}"> <c:forEach var="Classroom" items="${requestScope.pageBean.pageData}" varStatus="vs"> <tr> <td>${vs.count }</td> <td>${Classroom.classroomname }</td> <td>${Classroom.classroomtype }</td> <td>${Classroom.classroomcapacity }</td> <td> </td> </tr> </c:forEach> </c:if>
网页一访问通过了
为什么${Classroom.classroomname }可以通过而${Classroom.classroomid }却不可以通过呢,继续检查Classroom实体类
回到jsp将${Classroom.classroomid }改成${Classroom.classroomId }
重新部署,访问通过,好家伙
总结:myeclipse的报错还是要很认真分析的,还有这个错误让我对EL表达式的取值方法了解更深了,就是通过对外的公共方法来取值的,所以说名字一定要正确,同时对于这次myeclipse生成的代码我真的是郁闷爆了,认真检查!汲取教训。