目录
1.index.jsp 主界面
2.doIndex.jsp
3.购物车优化界面(Car.jsp)
1.index.jsp 主界面
<%@page import="com.zking.pojo.Goods"%>
<%@page import="com.zking.biz.impl.GoodsBizImpl"%>
<%@page import="com.zking.biz.IGoodsBiz"%>
<%@page import="com.zking.pojo.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="${pageContext.request.contextPath}/bootstrap-3.3.7-dist/css/bootstrap.css">
<script src="${pageContext.request.contextPath}/bootstrap-3.3.7-dist/js/jquery-3.5.1.js"></script>
<script src="${pageContext.request.contextPath}/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
<style>
td:nth-child(3)::before{
content: "$";
}
</style>
</head>
<body>
<c:if test="${user==null}">
<c:redirect url="login.jsp"></c:redirect>
</c:if>
<c:if test="${empty goods}"><c:redirect url="doIndex.jsp"></c:redirect></c:if>
<div class="jumbotron">
<div class="container">
<h1>欢迎光临 🌌源星球SuperMarket</h1>
<p>尊贵的${user.uname}</p>
<p><a href="Car.jsp" class="btn btn-primary">🛒</a></p>
<p><a href="doExit.jsp" class="btn btn-warning">退出</a></p>
</div>
</div>
<table class="table">
<tr>
<th>商品序号</th>
<th>商品名称</th>
<th>商品单价</th>
<th>商品描述</th>
<th>操作</th>
</tr>
<c:forEach items="${goods}" var="g">
<tr>
<td>${g.id}</td>
<td>${g.name}</td>
<td>${g.price}</td>
<td>${g.info}</td>
<td>
<div class="btn-group btn-group-xs">
<button class="btn btn-primary"><span class="glyphicon glyphicon-tags"></span></button>
<%--链接这里需要带id过去 --%>
<a href="doAddCar.jsp?id=${g.id}" class="btn btn-primary">添加购物车</a>
</div>
</td>
</tr>
</c:forEach>
</table>
<div style="text-align:center">
<ul class="pagination" style="">
<li>
<a href="doIndex.jsp?ipage=${Math.max(i-1,1)}">
<span aria-hidden="true">«</span>
</a>
</li>
<c:forEach begin="1" end="${maxPage}" var="i">
<li class="${ipage==i?"active":""}"><a href="doIndex.jsp?ipage=${i}">${i}</a></li>
</c:forEach>
<li><a href="doIndex.jsp?ipage=${i+1==maxPage?maxPage:i+1}" aria-label="Next"><span aria-hidden="true">»</span></a></li>
</ul>
</div>
</body></html>