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> <c:otherwise> <td colspan="3">暂未添加任何菜系!</td> </c:otherwise> </c:choose>
Servlet传过来的foodList是有值的,如果直接用 forEach 是可以显示的 为什么加了 test 判定就不行了呢? 困扰了很久 网上也没有找到答案 希望有大神可以解答!
付费偷看金额在0.1-10元之间
一周热门 更多>