//凉凉的心
try {
//调用业务层:
ProductService productService=new ProductService();
List<Product> list=productService.findAll();
request.setAttribute("list", list);
request.getRequestDispatcher("/dodo/list.jsp").forward(request, response);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>商品列表</h1>
<table border="1" width="1000">
<tr>
<td>商品编号</td>
<td>商品名称</td>
<td>商品价格</td>
<td>商品热门</td>
<td>商品描述</td>
</tr>
<c:forEach var="p" items="${list }" varStatus="sta"><!-- varStatus="sta"顺序查询 -->
<tr>
<td>${sta.count }</td>
<td>${p.pname }</td>
<td>${p.shop_price }</td>
<td>
<c:if test="${ p.is_hot == 1 }" >是</c:if>
<c:if test="${ p.is_hot != 1 }" >不是</c:if>
</td>
<td>${p.pdesc }</td>
</tr>
</c:forEach>
</table>
</body>
</html>
|
|