Servlet转发到JSP,JSP取出值输出不显示问题

Servlet代码

//DAO取数据

List<Dishes> list = sDao.findAllDishes();

//将其放到request的域中

request.setAttribute("dishesList", list);




JSP代码

        <%
request.setCharacterEncoding("utf-8");
List<Dishes> list = (List<Dishes>) request.getAttribute("dishesList");

%>

//这里的list控制台打印有值

//但是JTSL输出不了

        <div>
<c:forEach  var="Dishes" items="${pageScope.list}">
<div>${Dishes.dishesName}</div>
</c:forEach>

</div>

DBUG

//包导了//没写错

so google

//在jsp的<%%>中将LIST存入Page域

//取出 成了

items="${cg}" 你把cg放到某个scope下。再在scope中读出来。比如:pageContext.setAttribute("liset",liset);

ody>
<%
request.setCharacterEncoding("utf-8");
List<Dishes> list = (List<Dishes>) request.getAttribute("dishesList");
pageContext.setAttribute("list",list);
%>
<div>
<c:forEach  var="Dishes" items="${pageScope.list}">
<div>${Dishes.dishesName}</div>
</c:forEach>
</div>

//mark





展开阅读全文

没有更多推荐了,返回首页