Servlet代码:
List<FoodType> foodList = service.findAll(); request.setAttribute("foodList", foodList); // 2. 跳转 uri = "/sys/type/foodtype_list.jsp"; request.getRequestDispatcher(uri).forward(request, response);
以下是jsp的显示代码:
<c:choose> <c:when test="${not empty requestScope.foodList} "> <c:forEach items="${requestScope.foodList }" var="foodType" varStatus="vs"> <tr> <td>${vs.count }</td> <td>${foodType.foodTypeName }</td> <td><a href="${pageContext.request.contextPath }/FoodTypeServlet?method=editview&id=${foodType.id}" class="FunctionButton">更新</a> <a href="${pageContext.request.contextPath }/FoodTypeServlet?method=delete&id=${foodType.id}" class="FunctionButton">删除</a></td> </tr> </c:forEach></c:when> <优艾设计网_Photoshop论坛;c:otherwise> <td colspan="3">暂未添加任何菜系!</td> </c:otherwise> </c:choose>
Servlet传过来的foodList是有值的,如果直接用 forEach 是可以显示的 为什么加了 test 判定就不行了呢? 困扰了很久 网上也没有找到答案 希望有大神可以解答!
精彩评论