//servlet
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/html;charset=UTF-8");
List productList=null;
try {
productList = service.FindAllProduct();
} catch (SQLException e) {
e.printStackTrace();
}
if(productList!=null) {
//request域中存数据
req.setAttribute("productList", productList);
//转发给jsp
req.getRequestDispatcher("/admin/product/list.jsp").forward(req, resp);
}else{
System.out.println("查询失败");
}
}
//jsp
<%
System.out.println(request.getAttribute("productList"));
%>
<c:forEach items="${requestScope.productList}" var="product" varStatus="vs">
<tr onmouseover="this.style.backgroundColor = 'white'"
onmouseout="this.style.backgroundColor = '#F5FAFE';">
<td style="CURSOR: hand; HEIGHT: 22px" align="center"
width="18%">${vs.count}</td>
<td style="CURSOR: hand; HEIGHT: 22px" align="center"
width="17%"><img width="40" height="45" src="${pageContext.request.contextPath}/${product.pimage}"></td>
<td style="CURSOR: hand; HEIGHT: 22px" align="center"
width="17%">${product.pname}</td>
<td style="CURSOR: hand; HEIGHT: 22px" align="center"
width="17%">product.shop_price</td>
<td style="CURSOR: hand; HEIGHT: 22px" align="center"
width="17%">${product.is_hot==1?"是":"否"}</td>
<td align="center" style="HEIGHT: 22px"><a
href="${ pageContext.request.contextPath }/admin/product/edit.jsp">
<img
src="${pageContext.request.contextPath}/images/i_edit.gif"
border="0" style="CURSOR: hand">
</a></td>
<td align="center" style="HEIGHT: 22px"><a href="#"> <img
src="${pageContext.request.contextPath}/images/i_del.gif"
width="16" height="16" border="0" style="CURSOR: hand">
</a></td>
</tr>
</c:forEach>