jsp 显示不了刚查询出来的结果

Alaska_Lee Alaska_Lee 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

<%@ page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false"%>
<%-- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> --%>
<jsp:directive.page import="com.smoothlybelt.dao.ProductDao"/>
<jsp:directive.page import="com.smoothlybelt.been.Product"/>
<jsp:directive.page import="java.util.List"/>
<jsp:directive.page import="java.util.Iterator"/>

<%
List<Product> productList = ProductDao.listProducts();
Iterator<Product> it = productList.iterator();
while(it.hasNext()){
Product p = it.next();
System.out.println(p.getProductId());
System.out.println(p.getStoreId());
System.out.println(p.getSalesTotalVolume());
System.out.println(p.getProductEvalute());
}

request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
request.setAttribute("productList", productList);

%>

<html text-algin="center">

<form action="" method = get>
<table bgcolor = #cccccc cellspacing=1 cellpadding=5 width=100% >
<tr bgcolor=#dddddd>

<th>产品ID</th>
<th>商店ID</th>
<th>产品价格</th>
<th>产品状态</th>
<th>发布时间</th>
<th>产品总销量</th>
<th>最小免费金额</th>
</tr>
<c:forEach items="${productList} " var="product">
<tr bgcolor=#dddddd height=50>
<td>${product.productId}</td>
<td>${product.storeId}</td>
<td>${product.productPrise}</td>
<td>${product.productState}</td>
<td>${product.publishTime}</td>
<td>${product.salesTotalVolume}</td>
<td>${product.minFreeCost}</td>
</tr>
</c:forEach>
</table>
</form>

</html>


本人刚学java web,按书上写了个例子。
productList中可以明确是有结果的,while循环里面的结果也是可以打出来的,但是为什么最终页面表格里面显示不出数据?
...全文

相关推荐

评论 11
收藏 已收藏
分享
返回顶部