Compare commits

..

No commits in common. "58d20e5b1b0d9ef2d42a8fa17221af3c7368f711" and "e2b6123de8666bc3befea2b6a6df435d47e87b46" have entirely different histories.

16 changed files with 176 additions and 1183 deletions

View File

@ -1,27 +0,0 @@
package example.controller;
import example.dao.UserDao;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/deleteUserServlet")
public class DeleteUserServlet extends HttpServlet {
UserDao userDao=new UserDao();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String id = req.getParameter("id");
try {
userDao.deleteUser(Integer.parseInt(id));
req.getRequestDispatcher("/user?action=list").forward(req,resp);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@ -26,7 +26,7 @@ public class LoginServlet extends HttpServlet {
User user = userService.login(username, password); User user = userService.login(username, password);
if(user!=null){ if(user!=null){
req.getSession().setAttribute("user",user); req.getSession().setAttribute("user",user);
resp.sendRedirect("/computer?action=list"); resp.sendRedirect("/index.jsp");
}else{ }else{
req.getSession().setAttribute("msg","用户名或密码错误"); req.getSession().setAttribute("msg","用户名或密码错误");
resp.sendRedirect("/msg.jsp"); resp.sendRedirect("/msg.jsp");

View File

@ -28,9 +28,13 @@ public class RegisterServlet extends HttpServlet {
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
response.setContentType("text/html; charset=UTF-8");
response.setCharacterEncoding("UTF-8");
response.getWriter().println("<html><body>");
response.getWriter().println("</body></html>");
if (save > 0) { if (save > 0) {
request.setAttribute("msg","注册成功"); response.getWriter().println("注册成功~");
request.getRequestDispatcher("msg.jsp").forward(request, response);
} else { } else {
response.getWriter().println("注册失败~"); response.getWriter().println("注册失败~");
} }

View File

@ -6,76 +6,8 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>电脑产品发布</title> <title>电脑产品发布</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff; /* 天蓝色背景 */
color: #333; /* 深色文本 */
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
h1 {
color: #4682b4; /* 天蓝色标题 */
margin-bottom: 20px;
}
form {
background-color: #ffffff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
width: 300px;
text-align: center;
}
label {
font-size: 14px;
color: #4682b4; /* 天蓝色标签 */
display: block;
margin-bottom: 8px;
}
input[type="text"] {
width: 100%;
padding: 8px;
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
input[type="submit"] {
background-color: #4682b4; /* 天蓝色按钮 */
color: white;
padding: 10px;
border: none;
border-radius: 4px;
width: 100%;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #5a9bd3; /* 按钮悬停时颜色 */
}
a {
display: block;
margin-top: 10px;
color: #4682b4; /* 天蓝色链接 */
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head> </head>
<body> <body>
<div>
<h1>电脑产品发布</h1> <h1>电脑产品发布</h1>
<form action="/computer?action=add" method="post"> <form action="/computer?action=add" method="post">
<label for="name">名称: </label><br> <label for="name">名称: </label><br>
@ -88,6 +20,5 @@
</form> </form>
<br> <br>
<a href="/computer?action=list">返回电脑列表</a> <a href="/computer?action=list">返回电脑列表</a>
</div>
</body> </body>
</html> </html>

View File

@ -7,119 +7,10 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>购物车</title> <title>购物车</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff; /* 天蓝色背景 */
color: #333; /* 深色文本 */
margin: 0;
padding: 0;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
h2 {
color: #4682b4; /* 天蓝色标题 */
margin-top: 20px;
}
h1 {
color: #4682b4; /* 天蓝色产品列表标题 */
margin-top: 20px;
}
a {
color: #4682b4;
text-decoration: none;
margin: 0 10px;
}
a:hover {
text-decoration: underline;
}
table {
width: 80%;
margin-top: 20px;
border-collapse: collapse;
background-color: #fff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
th, td {
padding: 12px;
text-align: left;
border: 1px solid #ddd;
}
th {
background-color: #4682b4;
color: white;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #e6f7ff;
}
.pagination {
margin-top: 20px;
text-align: center;
}
.pagination a {
padding: 8px 16px;
margin: 0 5px;
background-color: #4682b4;
color: white;
border-radius: 4px;
}
.pagination a:hover {
background-color: #5a9bd3;
}
.message {
text-align: center;
margin-top: 20px;
color: #d9534f; /* 红色错误信息 */
}
</style>
</head> </head>
<body> <body>
<div>
<h2>电脑商城</h2>
<p>你好!${sessionScope.user.username}</p>
<c:if test="${sessionScope.user!= null}">
<a href="/computer?action=list">电脑选购</a>
<c:if test="${sessionScope.user.role == 'user'}">
<a href="/cart?action=list">我的购物车</a>
<a href="/orders?action=my">我的订单</a>
</c:if>
<c:if test="${sessionScope.user.role == 'admin'}">
<a href="/user?action=list">用户列表</a>
<a href="/orders?action=all">所有订单</a>
</c:if>
<a href="/logout">退出</a>
</c:if>
<c:if test="${sessionScope.user == null}">
<p>请登录后查看更多内容~</p>
<br>
<a href="/register">注册</a>
<a href="/login">登录</a>
</c:if>
</div>
<h1>购物车</h1> <h1>购物车</h1>
<a href="/">主页</a>
<c:if test="${not empty computers}"> <c:if test="${not empty computers}">
<table border="1"> <table border="1">
<thead> <thead>

View File

@ -7,80 +7,8 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>订单确认</title> <title>订单确认</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff; /* 天蓝色背景 */
color: #333; /* 深色文本 */
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
h1 {
color: #4682b4; /* 天蓝色标题 */
margin-bottom: 20px;
}
form {
background-color: #ffffff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
width: 300px;
text-align: center;
}
label {
font-size: 14px;
color: #4682b4; /* 天蓝色标签 */
display: block;
margin-bottom: 8px;
}
input[type="text"], textarea {
width: 100%;
padding: 8px;
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
textarea {
resize: vertical;
}
input[type="submit"] {
background-color: #4682b4; /* 天蓝色按钮 */
color: white;
padding: 10px;
border: none;
border-radius: 4px;
width: 100%;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #5a9bd3; /* 按钮悬停时颜色 */
}
a {
display: block;
margin-top: 10px;
color: #4682b4; /* 天蓝色链接 */
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head> </head>
<body> <body>
<div>
<h1>订单确认</h1> <h1>订单确认</h1>
<form action="/orders" method="post"> <form action="/orders" method="post">
<label for="price">总金额: </label><br> <label for="price">总金额: </label><br>
@ -92,7 +20,6 @@
<input type="submit" value="我已确认"> <input type="submit" value="我已确认">
</form> </form>
<br> <br>
<a href="/orders?action=my">返回订单列表</a> <a href="/">主页</a>
</div>
</body> </body>
</html> </html>

View File

@ -4,90 +4,6 @@
<html lang="en"> <html lang="en">
<head> <head>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff; /* 天蓝色背景 */
color: #333; /* 深色文本 */
margin: 0;
padding: 0;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
h2 {
color: #4682b4; /* 天蓝色标题 */
margin-top: 20px;
}
h1 {
color: #4682b4; /* 天蓝色产品列表标题 */
margin-top: 20px;
}
a {
color: #4682b4;
text-decoration: none;
margin: 0 10px;
}
a:hover {
text-decoration: underline;
}
table {
width: 80%;
margin-top: 20px;
border-collapse: collapse;
background-color: #fff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
th, td {
padding: 12px;
text-align: left;
border: 1px solid #ddd;
}
th {
background-color: #4682b4;
color: white;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #e6f7ff;
}
.pagination {
margin-top: 20px;
text-align: center;
}
.pagination a {
padding: 8px 16px;
margin: 0 5px;
background-color: #4682b4;
color: white;
border-radius: 4px;
}
.pagination a:hover {
background-color: #5a9bd3;
}
.message {
text-align: center;
margin-top: 20px;
color: #d9534f; /* 红色错误信息 */
}
</style>
<script src="https://www.liyansheng.top/cdn/watermark.js"></script> <script src="https://www.liyansheng.top/cdn/watermark.js"></script>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -95,36 +11,8 @@
</head> </head>
<body> <body>
<div>
<h2>电脑商城</h2>
<p>你好!${sessionScope.user.username}</p>
<c:if test="${sessionScope.user != null}">
<a href="/computer?action=list">电脑选购</a>
<c:if test="${sessionScope.user.role == 'user'}">
<a href="/cart?action=list">我的购物车</a>
<a href="/orders?action=my">我的订单</a>
</c:if>
<c:if test="${sessionScope.user.role == 'admin'}">
<a href="/user?action=list">用户列表</a>
<a href="/orders?action=all">所有订单</a>
</c:if>
<a href="/logout">退出</a>
</c:if>
<c:if test="${sessionScope.user == null}">
<p>请登录后查看更多内容~</p>
<br>
<a href="/register">注册</a>
<a href="/login">登录</a>
</c:if>
</div>
<h1>电脑产品列表</h1> <h1>电脑产品列表</h1>
<c:if test="${sessionScope.user.role == 'admin'}"> <table border="1">
<a href="/computer?action=add">发布电脑产品</a>
</c:if>
<table>
<thead> <thead>
<tr> <tr>
<th>ID</th> <th>ID</th>
@ -147,6 +35,7 @@
<a href="/computer?action=delete&id=${computer.id}">删除</a> <a href="/computer?action=delete&id=${computer.id}">删除</a>
</c:if> </c:if>
<c:if test="${sessionScope.user.role == 'user'}"> <c:if test="${sessionScope.user.role == 'user'}">
<a href="/cart?action=add&id=${computer.id}">加购</a> <a href="/cart?action=add&id=${computer.id}">加购</a>
</c:if> </c:if>
@ -155,7 +44,7 @@
</c:forEach> </c:forEach>
</tbody> </tbody>
</table> </table>
<div class="pagination"> <div>
<!-- 首页链接 --> <!-- 首页链接 -->
<a href="/computer?action=list&page=1">首页</a> <a href="/computer?action=list&page=1">首页</a>
@ -180,17 +69,18 @@
<!-- 尾页链接 --> <!-- 尾页链接 -->
<a href="/computer?action=list&page=${totalPages}">尾页</a> <a href="/computer?action=list&page=${totalPages}">尾页</a>
</div> </div>
<hr> <hr>
<p class="message">${requestScope.msg}</p> <p style="color: red;">${requestScope.msg}</p>
<br /> <br />
<c:if test="${sessionScope.user.role == 'user'}"> <c:if test="${sessionScope.user.role == 'user'}">
<a href="/cart?action=list">我的购物车</a> <a href="/cart?action=list">我的购物车</a>
</c:if> </c:if>
<c:if test="${sessionScope.user.role == 'admin'}">
<a href="/computer?action=add">发布电脑产品</a>
</c:if>
<br> <br>
<a href="/">主页</a>
</body> </body>
</html> </html>

View File

@ -7,76 +7,8 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>更新电脑信息</title> <title>更新电脑信息</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff; /* 天蓝色背景 */
color: #333; /* 深色文本 */
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
h1 {
color: #4682b4; /* 天蓝色标题 */
margin-bottom: 20px;
}
form {
background-color: #ffffff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
width: 300px;
text-align: center;
}
label {
font-size: 14px;
color: #4682b4; /* 天蓝色标签 */
display: block;
margin-bottom: 8px;
}
input[type="text"] {
width: 100%;
padding: 8px;
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
input[type="submit"] {
background-color: #4682b4; /* 天蓝色按钮 */
color: white;
padding: 10px;
border: none;
border-radius: 4px;
width: 100%;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #5a9bd3; /* 按钮悬停时颜色 */
}
a {
display: block;
margin-top: 10px;
color: #4682b4; /* 天蓝色链接 */
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head> </head>
<body> <body>
<div>
<h1>更新电脑信息</h1> <h1>更新电脑信息</h1>
<form action="/computer?action=edit" method="post"> <form action="/computer?action=edit" method="post">
<input type="hidden" name="id" value="${computer.id}"> <input type="hidden" name="id" value="${computer.id}">
@ -90,6 +22,5 @@
</form> </form>
<br> <br>
<a href="/computer?action=list">返回电脑列表</a> <a href="/computer?action=list">返回电脑列表</a>
</div>
</body> </body>
</html> </html>

View File

@ -3,8 +3,7 @@
<html> <html>
<body> <body>
<script src="https://www.liyansheng.top/cdn/watermark.js"></script> <script src="https://www.liyansheng.top/cdn/watermark.js"></script>
<div> <h2>电脑商城-首页</h2>
<h2>电脑商城</h2>
<p>你好!${sessionScope.user.username}</p> <p>你好!${sessionScope.user.username}</p>
<c:if test="${sessionScope.user!= null}"> <c:if test="${sessionScope.user!= null}">
<a href="/computer?action=list">电脑选购</a> <a href="/computer?action=list">电脑选购</a>
@ -26,7 +25,6 @@
<a href="/register">注册</a> <a href="/register">注册</a>
<a href="/login">登录</a> <a href="/login">登录</a>
</c:if> </c:if>
</div>
</body> </body>

View File

@ -3,84 +3,10 @@
<html> <html>
<head> <head>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff; /* 天蓝色背景 */
color: #333; /* 深色文本 */
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
h2 {
color: #4682b4; /* 天蓝色标题 */
margin-bottom: 20px;
}
form {
background-color: #ffffff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
width: 300px;
text-align: center;
}
label {
font-size: 14px;
color: #4682b4; /* 天蓝色标签 */
display: block;
margin-bottom: 8px;
}
input {
width: 100%;
padding: 8px;
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
background-color: #4682b4; /* 天蓝色按钮 */
color: white;
padding: 10px;
border: none;
border-radius: 4px;
width: 100%;
cursor: pointer;
}
button:hover {
background-color: #5a9bd3; /* 按钮悬停时颜色 */
}
a {
display: block;
margin-top: 10px;
color: #4682b4; /* 天蓝色链接 */
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.message {
text-align: center;
margin-top: 20px;
color: #d9534f; /* 红色错误信息 */
}
</style>
<script src="https://www.liyansheng.top/cdn/watermark.js"></script> <script src="https://www.liyansheng.top/cdn/watermark.js"></script>
</head> </head>
<body> <body>
<div>
<h2>-电脑商城-用户登录</h2> <h2>-电脑商城-用户登录</h2>
<form action="login" method="post"> <form action="login" method="post">
<label for="username">用户名:</label> <label for="username">用户名:</label>
@ -91,8 +17,7 @@
<a href="/register">没有账号?去注册</a> <a href="/register">没有账号?去注册</a>
</form> </form>
<br> <br>
<div class="message">${requestScope.msg}</div> ${requestScope.msg}
</div>
</body> </body>
</html> </html>

View File

@ -4,49 +4,13 @@
<head> <head>
<script src="https://www.liyansheng.top/cdn/watermark.js"></script> <script src="https://www.liyansheng.top/cdn/watermark.js"></script>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff; /* 天蓝色背景 */
color: #333; /* 深色文本 */
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
flex-direction: column;
}
h2 {
color: #4682b4; /* 天蓝色标题 */
margin-bottom: 20px;
}
h3 {
color: #d9534f; /* 红色提示信息 */
margin-bottom: 20px;
}
button {
background-color: #4682b4; /* 天蓝色按钮 */
color: white;
padding: 10px;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #5a9bd3; /* 按钮悬停时颜色 */
}
</style>
</head> </head>
<body> <body>
<h2>提示:</h2> <h2>提示:</h2>
<h3>${requestScope.msg}</h3> <h3>${sessionScope.msg}</h3>
<button onclick="window.history.back();">返回</button> <button onclick="window.history.back();">返回</button>
</body> </body>
</html> </html>

View File

@ -7,117 +7,8 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>我的订单</title> <title>我的订单</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff; /* 天蓝色背景 */
color: #333; /* 深色文本 */
margin: 0;
padding: 0;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
h2 {
color: #4682b4; /* 天蓝色标题 */
margin-top: 20px;
}
h1 {
color: #4682b4; /* 天蓝色产品列表标题 */
margin-top: 20px;
}
a {
color: #4682b4;
text-decoration: none;
margin: 0 10px;
}
a:hover {
text-decoration: underline;
}
table {
width: 80%;
margin-top: 20px;
border-collapse: collapse;
background-color: #fff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
th, td {
padding: 12px;
text-align: left;
border: 1px solid #ddd;
}
th {
background-color: #4682b4;
color: white;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #e6f7ff;
}
.pagination {
margin-top: 20px;
text-align: center;
}
.pagination a {
padding: 8px 16px;
margin: 0 5px;
background-color: #4682b4;
color: white;
border-radius: 4px;
}
.pagination a:hover {
background-color: #5a9bd3;
}
.message {
text-align: center;
margin-top: 20px;
color: #d9534f; /* 红色错误信息 */
}
</style>
</head> </head>
<body> <body>
<div>
<h2>电脑商城</h2>
<p>你好!${sessionScope.user.username}</p>
<c:if test="${sessionScope.user!= null}">
<a href="/computer?action=list">电脑选购</a>
<c:if test="${sessionScope.user.role == 'user'}">
<a href="/cart?action=list">我的购物车</a>
<a href="/orders?action=my">我的订单</a>
</c:if>
<c:if test="${sessionScope.user.role == 'admin'}">
<a href="/user?action=list">用户列表</a>
<a href="/orders?action=all">所有订单</a>
</c:if>
<a href="/logout">退出</a>
</c:if>
<c:if test="${sessionScope.user == null}">
<p>请登录后查看更多内容~</p>
<br>
<a href="/register">注册</a>
<a href="/login">登录</a>
</c:if>
</div>
<h1>我的订单</h1> <h1>我的订单</h1>
<div style="color: red;"> <div style="color: red;">
@ -151,6 +42,6 @@
</table> </table>
<br/> <br/>
<br> <br>
<a href="/">主页</a>
</body> </body>
</html> </html>

View File

@ -8,119 +8,13 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>订单列表</title> <title>订单列表</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff; /* 天蓝色背景 */
color: #333; /* 深色文本 */
margin: 0;
padding: 0;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
h2 {
color: #4682b4; /* 天蓝色标题 */
margin-top: 20px;
}
h1 {
color: #4682b4; /* 天蓝色产品列表标题 */
margin-top: 20px;
}
a:hover {
text-decoration: underline;
}
table {
width: 80%;
margin-top: 20px;
border-collapse: collapse;
background-color: #fff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
th, td {
padding: 12px;
text-align: left;
border: 1px solid #ddd;
}
th {
background-color: #4682b4;
color: white;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #e6f7ff;
}
.pagination {
margin-top: 20px;
text-align: center;
}
.pagination a {
padding: 8px 16px;
margin: 0 5px;
background-color: #4682b4;
color: white;
border-radius: 4px;
}
.pagination a:hover {
background-color: #5a9bd3;
}
.message {
text-align: center;
margin-top: 20px;
color: #d9534f; /* 红色错误信息 */
}
</style>
</head> </head>
<body> <body>
<div>
<h2>电脑商城</h2>
<p>你好!${sessionScope.user.username}</p>
<c:if test="${sessionScope.user!= null}">
<a href="/computer?action=list">电脑选购</a>
<c:if test="${sessionScope.user.role == 'user'}">
<a href="/cart?action=list">我的购物车</a>
<a href="/orders?action=my">我的订单</a>
</c:if>
<c:if test="${sessionScope.user.role == 'admin'}">
<a href="/user?action=list">用户列表</a>
<a href="/orders?action=all">所有订单</a>
</c:if>
<a href="/logout">退出</a>
</c:if>
<c:if test="${sessionScope.user == null}">
<p>请登录后查看更多内容~</p>
<br>
<a href="/register">注册</a>
<a href="/login">登录</a>
</c:if>
</div>
<h1>订单列表</h1> <h1>订单列表</h1>
<div> <a href="/orders?action=all">全部</a> |
<p> <a href="/orders?action=all">全部</a> |
<a href="/orders?action=waiting">待发货</a> | <a href="/orders?action=waiting">待发货</a> |
<a href="/orders?action=sent">已发货</a></p> <a href="/orders?action=sent">已发货</a>
</div>
<br> <br>
<br> <br>
<table border="1"> <table border="1">
@ -158,7 +52,7 @@
</table> </table>
<br /> <br />
<br> <br>
<a href="/">主页</a>
</body> </body>
</html> </html>

View File

@ -3,84 +3,10 @@
<html> <html>
<head> <head>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff; /* 天蓝色背景 */
color: #333; /* 深色文本 */
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
h2 {
color: #4682b4; /* 天蓝色标题 */
margin-bottom: 20px;
}
form {
background-color: #ffffff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
width: 300px;
text-align: center;
}
label {
font-size: 14px;
color: #4682b4; /* 天蓝色标签 */
display: block;
margin-bottom: 8px;
}
input {
width: 100%;
padding: 8px;
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
background-color: #4682b4; /* 天蓝色按钮 */
color: white;
padding: 10px;
border: none;
border-radius: 4px;
width: 100%;
cursor: pointer;
}
button:hover {
background-color: #5a9bd3; /* 按钮悬停时颜色 */
}
a {
display: block;
margin-top: 10px;
color: #4682b4; /* 天蓝色链接 */
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.message {
text-align: center;
margin-top: 20px;
color: #d9534f; /* 红色错误信息 */
}
</style>
<script src="https://www.liyansheng.top/cdn/watermark.js"></script> <script src="https://www.liyansheng.top/cdn/watermark.js"></script>
</head> </head>
<body> <body>
<div>
<h2>用户注册</h2> <h2>用户注册</h2>
<form action="register" method="post"> <form action="register" method="post">
<label for="username">用户名:</label> <label for="username">用户名:</label>
@ -93,8 +19,7 @@
<a href="/login">已有账号,去登录</a> <a href="/login">已有账号,去登录</a>
</form> </form>
<br> <br>
<div class="message">${requestScope.msg}</div> ${requestScope.msg}
</div>
</body> </body>
</html> </html>

View File

@ -7,56 +7,14 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>操作结果</title> <title>操作结果</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff; /* 天蓝色背景 */
color: #333; /* 深色文本 */
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
flex-direction: column;
}
h1 {
color: #4682b4; /* 天蓝色标题 */
margin-bottom: 20px;
}
.message {
color: red; /* 错误信息红色 */
font-size: 16px;
margin-bottom: 20px;
text-align: center;
}
button {
background-color: #4682b4; /* 天蓝色按钮 */
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #5a9bd3; /* 按钮悬停时颜色 */
}
</style>
</head> </head>
<body> <body>
<div>
<h1>操作结果</h1> <h1>操作结果</h1>
<div class="message"> <div style="color: red;">
<p>${requestScope.msg}</p> <p>${requestScope.msg}</p>
</div> </div>
<br>
<a href="orders?action=my">返回我的订单</a> <a href="/">主页</a>
</div>
</body> </body>
</html> </html>

View File

@ -7,117 +7,8 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>系统用户</title> <title>系统用户</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff; /* 天蓝色背景 */
color: #333; /* 深色文本 */
margin: 0;
padding: 0;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
h2 {
color: #4682b4; /* 天蓝色标题 */
margin-top: 20px;
}
h1 {
color: #4682b4; /* 天蓝色产品列表标题 */
margin-top: 20px;
}
a {
color: #4682b4;
text-decoration: none;
margin: 0 10px;
}
a:hover {
text-decoration: underline;
}
table {
width: 80%;
margin-top: 20px;
border-collapse: collapse;
background-color: #fff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
th, td {
padding: 12px;
text-align: left;
border: 1px solid #ddd;
}
th {
background-color: #4682b4;
color: white;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #e6f7ff;
}
.pagination {
margin-top: 20px;
text-align: center;
}
.pagination a {
padding: 8px 16px;
margin: 0 5px;
background-color: #4682b4;
color: white;
border-radius: 4px;
}
.pagination a:hover {
background-color: #5a9bd3;
}
.message {
text-align: center;
margin-top: 20px;
color: #d9534f; /* 红色错误信息 */
}
</style>
</head> </head>
<body> <body>
<div>
<h2>电脑商城</h2>
<p>你好!${sessionScope.user.username}</p>
<c:if test="${sessionScope.user!= null}">
<a href="/computer?action=list">电脑选购</a>
<c:if test="${sessionScope.user.role == 'user'}">
<a href="/cart?action=list">我的购物车</a>
<a href="/orders?action=my">我的订单</a>
</c:if>
<c:if test="${sessionScope.user.role == 'admin'}">
<a href="/user?action=list">用户列表</a>
<a href="/orders?action=all">所有订单</a>
</c:if>
<a href="/logout">退出</a>
</c:if>
<c:if test="${sessionScope.user == null}">
<p>请登录后查看更多内容~</p>
<br>
<a href="/register">注册</a>
<a href="/login">登录</a>
</c:if>
</div>
<h1>系统用户</h1> <h1>系统用户</h1>
<table border="1"> <table border="1">
<thead> <thead>
@ -137,7 +28,7 @@
<td>${user.phone}</td> <td>${user.phone}</td>
<td>${user.role}</td> <td>${user.role}</td>
<td> <td>
<a href="/deleteUserServlet?id=${user.id}" >删除</a> <a href="javascript:void(0)" >Delete</a>
</td> </td>
</tr> </tr>
</c:forEach> </c:forEach>
@ -145,6 +36,6 @@
</table> </table>
<br/> <br/>
<!-- <a href="/adduser">Add New user</a> --> <!-- <a href="/adduser">Add New user</a> -->
<a href="/">主页</a>
</body> </body>
</html> </html>