jsp 显示不了刚查询出来的结果
<%@ 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循环里面的结果也是可以打出来的,但是为什么最终页面表格里面显示不出数据?
...全文
相关推荐
使用EL和JSTL显示查询结果
使用EL和JSTL,实现从Servlet中获取信息,然后在显示页面显示结果
完整JSP模糊查询完整JSP模糊查询
完整JSP模糊查询,五种模糊查询
通过JSP将数据库中的数据显示到网页上
通过JSP将数据库中的数据显示到网页上,数据库为Mysql数据库。
jsp页面常用的查询及显示方法分析
本文实例讲述了jsp页面常用的查询及显示方法。分享给大家供大家参考,具体如下: 背景: 1. 需要将数据库查询结果在JSP中以列表方式显示 2. 在一个良好的J2EE模式中数据库查询一般用DAO实现(Data Access Object), JSP仅用于显示数据 方法一: 建一个类,将查询出的结果封装到该类中,然后将该类对象添加到List中。(这个也是我最开始时用的方法,不通用且太麻烦了)。 方法二: 在介绍方法二的时候,我们先来看看如何把ResultSet转化为List吧,代码如下: private static List resultSetToList(ResultSet rs) thr
jsp带模糊查询的分页代码
运用servlet+mysql编写的模糊查询并且进行分页的例子


