jsp页面:
<c:forEach items="${books}" var="b">
<tr onmouseover="this.style.backgroundColor = 'white'" onmouseout="this.style.backgroundColor = '#F5FAFE';">
<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="23">${b.cId }</td>
<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="18%">${b.cName}</td>
<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="8%">${b.cPrice }</td>
<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="8%">${b.cCount }</td>
<td style="CURSOR: hand; HEIGHT: 22px" align="center">${b.cCategory }</td>
<td align="center" style="HEIGHT: 22px" width="7%">
<a href="${pageContext.request.contextPath}/admin/products/edit.jsp">
<img src="${pageContext.request.contextPath}/admin/images/i_edit.gif" border="0"
style="CURSOR: hand">
</a>
</td>
<td align="center" style="HEIGHT: 22px" width="7%">
<a href="#">
<img src="${pageContext.request.contextPath}/admin/images/i_del.gif" width="16"
height="16" border="0" style="CURSOR: hand">
</a>
</td>
</tr>
</c:forEach>
表单提交方式:
<form id="Form1" name="Form1"
action="${pageContext.request.contextPath}/servlet/findBookListServlet" method="post">
</form>
servlet代码:
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
req.setCharacterEncoding("UTF-8");
List<Commodity> bookList = service.getBookList();
if (bookList!=null) {
req.setAttribute("books", bookList);
req.getRequestDispatcher("/admin/products/list.jsp").forward(req, resp);
}else {
req.getRequestDispatcher("/admin/products/list.jsp").forward(req, resp);
}
}
效果是这样滴: