页面代码如下:
<tbody id="tb"> <c:forEach items="productTypes" var="productType"> <tr> <td>${productType.id}</td> <td>${productType.name}</td> <td> <c:if test="${productType.status == 1}">禁用</c:if> <c:if test="${productType.status == 0}">启用</c:if> </td> <td class="text-center"> <input type="button" class="btn btn-warning btn-sm doProTypeModify" value="修改"> <input type="button" class="btn btn-danger btn-sm doProTypeDisable" value="禁用"> </td> </tr> </c:forEach> </tbody>
报错信息:
SEVERE: Servlet.service() for servlet jsp threw exception
javax.el.PropertyNotFoundException: Property 'id' not found on type java.lang.String
at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:229)
at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:206)
at javax.el.BeanELResolver.property(BeanELResolver.java:317)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:85)
找了半天,眼都花了,一直执著地在循环处找错误。最后发现,开头的地方就错了,
<c:forEach items="productTypes" var="productType">
这一句,items="productTypes"改成这样:items="${productTypes}"才正确,确实是看了一天电脑,眼睛不行了,脑子也不行了!