一.login 登录
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<!-- 显示数据时,判断非空 -->
<c:if test="${empty listGoods }">
<jsp:forward page="load.do"></jsp:forward>
</c:if>
<h1 style="text-align: center;">我的购物商城首页</h1>
<div style="text-align: center;">
<form action="load.do" method="post">
名称<input type="text" name="strName">
<input type="submit" value ="搜索">
</form>
</div>
<table border="1" width="70%" align = "center">
<tr>
<th>编号</th>
<th>名称</th>
<th>价格</th>
<th>操作</th>
</tr>
<c:forEach items="${listGoods }" var="goods">
<tr>
<td>${goods.gid}</td>
<td>${goods.gname}</td>
<td>${goods.gprice}</td>
<td>
<button οnclick="addCart(${goods.gid})">加入购物车</button>
</td>
</tr>
</c:forEach>
</table>
<div style="text-align: center;">
[${pageIndex }/${pageMax }]
<a href="load.do?pageIndex=1">首页</a>
<a href="load.do?pageIndex=${pageIndex-1<0?1:pageIndex-1 }">上一页</a>
<a href="load.do?pageIndex=${pageIndex+1>pageMax?pageMax:pageIndex+1 }&strName=${strName}">下一页</a>
<a href="load.do?pageIndex=${pageMax }">尾页</a>
</div>
<script type="text/javascript">
//加入购物车的点击事件
function addCart(cid){
//alert(cid)
location.href = "/shopping.do?cid="+cid;
}
</script>
</body>
</html>
}