fix<页面结构调整>

master
liyansheng 2024-12-22 21:02:08 +08:00
parent e2b6123de8
commit 61cb1dec77
9 changed files with 155 additions and 28 deletions

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("/index.jsp"); resp.sendRedirect("/computer?action=list");
}else{ }else{
req.getSession().setAttribute("msg","用户名或密码错误"); req.getSession().setAttribute("msg","用户名或密码错误");
resp.sendRedirect("/msg.jsp"); resp.sendRedirect("/msg.jsp");

View File

@ -9,8 +9,33 @@
<title>购物车</title> <title>购物车</title>
</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

@ -20,6 +20,6 @@
<input type="submit" value="我已确认"> <input type="submit" value="我已确认">
</form> </form>
<br> <br>
<a href="/">主页</a>
</body> </body>
</html> </html>

View File

@ -11,6 +11,31 @@
</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>
@ -80,7 +105,7 @@
<a href="/computer?action=add">发布电脑产品</a> <a href="/computer?action=add">发布电脑产品</a>
</c:if> </c:if>
<br> <br>
<a href="/">主页</a>
</body> </body>
</html> </html>

View File

@ -3,28 +3,30 @@
<html> <html>
<body> <body>
<script src="https://www.liyansheng.top/cdn/watermark.js"></script> <script src="https://www.liyansheng.top/cdn/watermark.js"></script>
<h2>电脑商城-首页</h2> <div>
<p>你好!${sessionScope.user.username}</p> <h2>电脑商城</h2>
<c:if test="${sessionScope.user!= null}"> <p>你好!${sessionScope.user.username}</p>
<a href="/computer?action=list">电脑选购</a> <c:if test="${sessionScope.user!= null}">
<c:if test="${sessionScope.user.role == 'user'}"> <a href="/computer?action=list">电脑选购</a>
<a href="/cart?action=list">我的购物车</a> <c:if test="${sessionScope.user.role == 'user'}">
<a href="/orders?action=my">我的订单</a> <a href="/cart?action=list">我的购物车</a>
</c:if> <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 test="${sessionScope.user.role == 'admin'}">
<a href="/user?action=list">用户列表</a>
<a href="/orders?action=all">所有订单</a>
</c:if> </c:if>
<a href="/logout">退出</a> <c:if test="${sessionScope.user == null}">
<p>请登录后查看更多内容~</p>
</c:if> <br>
<c:if test="${sessionScope.user == null}"> <a href="/register">注册</a>
<p>请登录后查看更多内容~</p> <a href="/login">登录</a>
<br> </c:if>
<a href="/register">注册</a> </div>
<a href="/login">登录</a>
</c:if>
</body> </body>

View File

@ -9,6 +9,31 @@
<title>我的订单</title> <title>我的订单</title>
</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;">
@ -42,6 +67,6 @@
</table> </table>
<br/> <br/>
<br> <br>
<a href="/">主页</a>
</body> </body>
</html> </html>

View File

@ -11,6 +11,31 @@
</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="/orders?action=all">全部</a> | <a href="/orders?action=all">全部</a> |
<a href="/orders?action=waiting">待发货</a> | <a href="/orders?action=waiting">待发货</a> |
@ -52,7 +77,7 @@
</table> </table>
<br /> <br />
<br> <br>
<a href="/">主页</a>
</body> </body>
</html> </html>

View File

@ -15,6 +15,6 @@
<p>${requestScope.msg}</p> <p>${requestScope.msg}</p>
</div> </div>
<br> <br>
<a href="/">主页</a>
</body> </body>
</html> </html>

View File

@ -9,6 +9,31 @@
<title>系统用户</title> <title>系统用户</title>
</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>
@ -36,6 +61,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>