2024-12-21 01:22:44 +08:00
|
|
|
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
|
2024-12-21 18:06:18 +08:00
|
|
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<script src="https://www.liyansheng.top/cdn/watermark.js"></script>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>电脑产品列表</title>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<h1>电脑产品列表</h1>
|
|
|
|
<table border="1">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>ID</th>
|
|
|
|
<th>名称</th>
|
|
|
|
<th>价格</th>
|
|
|
|
<th>库存</th>
|
|
|
|
<th>操作</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<c:forEach var="computer" items="${computers}">
|
|
|
|
<tr>
|
|
|
|
<td>${computer.id}</td>
|
|
|
|
<td>${computer.name}</td>
|
|
|
|
<td>${computer.price}</td>
|
|
|
|
<td>${computer.stock}</td>
|
|
|
|
<td>
|
|
|
|
<c:if test="${sessionScope.user.role == 'admin'}">
|
2024-12-21 23:38:06 +08:00
|
|
|
<a href="/computer?action=edit&id=${computer.id}">编辑</a> |
|
|
|
|
<a href="/computer?action=delete&id=${computer.id}">删除</a>
|
2024-12-21 18:06:18 +08:00
|
|
|
</c:if>
|
|
|
|
|
|
|
|
|
|
|
|
<c:if test="${sessionScope.user.role == 'user'}">
|
|
|
|
<a href="/cart?action=add&id=${computer.id}">加购</a>
|
|
|
|
</c:if>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</c:forEach>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2024-12-22 01:38:37 +08:00
|
|
|
<div>
|
|
|
|
<!-- 首页链接 -->
|
|
|
|
<a href="/computer?action=list&page=1">首页</a>
|
|
|
|
|
|
|
|
<!-- 上一页链接 -->
|
|
|
|
<c:if test="${currentPage > 1}">
|
|
|
|
<a href="/computer?action=list&page=${currentPage - 1}">上一页</a>
|
|
|
|
</c:if>
|
|
|
|
|
|
|
|
<!-- 分页页码 -->
|
|
|
|
<c:forEach var="i" begin="1" end="${totalPages}">
|
|
|
|
<a href="/computer?action=list&page=${i}"
|
|
|
|
style="margin: 0 5px; ${i == currentPage ? 'font-weight:bold;' : ''}">
|
|
|
|
${i}
|
|
|
|
</a>
|
|
|
|
</c:forEach>
|
|
|
|
|
|
|
|
<!-- 下一页链接 -->
|
|
|
|
<c:if test="${currentPage < totalPages}">
|
|
|
|
<a href="/computer?action=list&page=${currentPage + 1}">下一页</a>
|
|
|
|
</c:if>
|
|
|
|
|
|
|
|
<!-- 尾页链接 -->
|
|
|
|
<a href="/computer?action=list&page=${totalPages}">尾页</a>
|
|
|
|
</div>
|
2024-12-21 18:06:18 +08:00
|
|
|
<hr>
|
|
|
|
<p style="color: red;">${requestScope.msg}</p>
|
|
|
|
|
|
|
|
<br />
|
|
|
|
<c:if test="${sessionScope.user.role == 'user'}">
|
|
|
|
<a href="/cart?action=list">我的购物车</a>
|
|
|
|
</c:if>
|
|
|
|
<c:if test="${sessionScope.user.role == 'admin'}">
|
2024-12-21 23:38:06 +08:00
|
|
|
<a href="/computer?action=add">发布电脑产品</a>
|
2024-12-21 18:06:18 +08:00
|
|
|
</c:if>
|
|
|
|
<br>
|
|
|
|
<a href="/">主页</a>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|