javax.el.PropertyNotFoundException: 类型[xx.xxx.xxxx]上找不到属性[xxxx]
今天在JSP利用EL表达式取值报了 "javax.el.PropertyNotFoundException”
1 Caused by: org.apache.jasper.JasperException: 在 [33] 行处理 [/course-list.jsp] 时发生异常 2 3 30: </tr> 4 31: <c:forEach var="course" items="${courses}"> 5 32: <tr> 6 33: <td>${course.CourseId}</td> 7 34: <td>${course.courseName}</td> 8 35: <td>${course.courseMajor}</td> 9 36: <td>${course.userName}</td> 10 11 12 Stacktrace: 13 at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:617) 14 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:514) 15 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) 16 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) 17 at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) 18 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 19 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 20 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 21 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 22 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 23 at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728) 24 at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:470) 25 at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:395) 26 at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:316) 27 at cn.cqsw.controller.CourseServlet.findAll(CourseServlet.java:33) 28 ... 30 more 29 Caused by: javax.el.PropertyNotFoundException: 类型[cn.cqsw.pojo.Course]上找不到属性[CourseId] 30 at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:260) 31 at javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:212) 32 at javax.el.BeanELResolver.property(BeanELResolver.java:333) 33 at javax.el.BeanELResolver.getValue(BeanELResolver.java:92) 34 at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110) 35 at org.apache.el.parser.AstValue.getValue(AstValue.java:169) 36 at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:190) 37 at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:944) 38 at org.apache.jsp.course_002dlist_jsp._jspx_meth_c_005fforEach_005f0(course_002dlist_jsp.java:192) 39 at org.apache.jsp.course_002dlist_jsp._jspService(course_002dlist_jsp.java:144) 40 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 41 at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) 42 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476) 43 ... 43 more
实体类
private Integer CourseId; private String courseName; private String courseMajor; private String userName; private String addDate;
修改
1 <c:forEach var="course" items="${courses}"> 2 <tr> 3 <td>${course.courseId}</td> 4 <td>${course.courseName}</td> 5 <td>${course.courseMajor}</td> 6 <td>${course.userName}</td> 7 <td>${course.addDate}</td> 8 <td><input type="button" value="删除" onclick="location.href='/course?method=delById&cid=${course.courseId}'"></td> 9 </tr> 10 </c:forEach>
将获取courseId的时候首字母改为了小写,成功获取到了现实的值。
希望对大家有用
本文来自博客园,作者:BaldHead,转载请注明原文链接:https://www.cnblogs.com/strict/p/12605425.html