From 78f115558366585c7d5a7a4c54c30c16369846d8 Mon Sep 17 00:00:00 2001 From: liyansheng <1761724207@qq.com> Date: Sat, 21 Dec 2024 18:06:18 +0800 Subject: [PATCH] =?UTF-8?q?fix<=E9=A1=B5=E9=9D=A2=E8=B0=83=E6=95=B4>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 2 +- src/main/java/example/dao/UserDao.java | 4 +- src/main/java/example/model/User.java | 14 ++-- src/main/webapp/addComputer.jsp | 15 ++-- src/main/webapp/cart.jsp | 1 + src/main/webapp/checkOrder.jsp | 1 + src/main/webapp/computerList.jsp | 105 ++++++++++++++----------- src/main/webapp/editComputer.jsp | 15 ++-- src/main/webapp/index.jsp | 19 +++-- src/main/webapp/myOrder.jsp | 5 +- src/main/webapp/orders.jsp | 1 + src/main/webapp/result.jsp | 1 + src/main/webapp/userList.jsp | 10 +-- 13 files changed, 110 insertions(+), 83 deletions(-) diff --git a/readme.md b/readme.md index fb7a7c8..b1c6290 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # jsp+servlet -## 全局过滤器的应用 +## 全局过滤器的应用(鉴权,异常统一处理) diff --git a/src/main/java/example/dao/UserDao.java b/src/main/java/example/dao/UserDao.java index eeabbad..8d4cfe5 100644 --- a/src/main/java/example/dao/UserDao.java +++ b/src/main/java/example/dao/UserDao.java @@ -12,8 +12,8 @@ public class UserDao { private final QueryRunner queryRunner = new QueryRunner(DBUtils.getDataSource()); public int addUser(String username, String phone,String password) throws Exception { - String sql = "INSERT INTO user (username,phone, password,admin) VALUES (?, ?,?,?)"; - return queryRunner.update(sql, username, phone,password,0); + String sql = "INSERT INTO user (username,phone, password,role) VALUES (?, ?,?,?)"; + return queryRunner.update(sql, username, phone,password,"user"); } public User getUserById(int id) throws Exception { diff --git a/src/main/java/example/model/User.java b/src/main/java/example/model/User.java index b8faa08..7792243 100644 --- a/src/main/java/example/model/User.java +++ b/src/main/java/example/model/User.java @@ -6,17 +6,17 @@ public class User { private int id; private String username; private String password; - private Boolean admin; + private String role; private String phone; public User() { } - public User(int id, String username, String password, Boolean admin, String phone) { + public User(int id, String username, String password, String role, String phone) { this.id = id; this.username = username; this.password = password; - this.admin = admin; + this.role=role; this.phone = phone; } @@ -44,12 +44,12 @@ public class User { this.password = password; } - public Boolean getAdmin() { - return admin; + public String getRole() { + return role; } - public void setAdmin(Boolean admin) { - this.admin = admin; + public void setRole(String role) { + this.role = role; } public String getPhone() { diff --git a/src/main/webapp/addComputer.jsp b/src/main/webapp/addComputer.jsp index 4b449e4..a801a3f 100644 --- a/src/main/webapp/addComputer.jsp +++ b/src/main/webapp/addComputer.jsp @@ -2,22 +2,23 @@ + - Add Computer + 电脑产品发布 -

Add New Computer

+

电脑产品发布

-
+


-
+


-
+


- +

- Back to List + 返回电脑列表 diff --git a/src/main/webapp/cart.jsp b/src/main/webapp/cart.jsp index bc001fd..b5a17ef 100644 --- a/src/main/webapp/cart.jsp +++ b/src/main/webapp/cart.jsp @@ -3,6 +3,7 @@ + 购物车 diff --git a/src/main/webapp/checkOrder.jsp b/src/main/webapp/checkOrder.jsp index 4ed32c8..9c8f68c 100644 --- a/src/main/webapp/checkOrder.jsp +++ b/src/main/webapp/checkOrder.jsp @@ -3,6 +3,7 @@ + 订单确认 diff --git a/src/main/webapp/computerList.jsp b/src/main/webapp/computerList.jsp index 38b60b1..cbc6a90 100644 --- a/src/main/webapp/computerList.jsp +++ b/src/main/webapp/computerList.jsp @@ -1,46 +1,61 @@ <%@ page contentType="text/html; charset=UTF-8" language="java" %> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - - - - - Computer List - - -

Computer List

- - - - - - - - - - - - - - - - - - - - - -
IDNamePriceStockActions
${computer.id}${computer.name}${computer.price}${computer.stock} - Edit | - Delete | - 加购 -
-
-

${requestScope.msg}

- 我的购物车 -
- Add New Computer -
- 主页 - - + <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + + + + + 电脑产品列表 + + + +

电脑产品列表

+ + + + + + + + + + + + + + + + + + + + + +
ID名称价格库存操作
${computer.id}${computer.name}${computer.price}${computer.stock} + + 编辑 | + 删除 + + + + + 加购 + +
+
+

${requestScope.msg}

+ +
+ + 我的购物车 + + + 发布电脑产品 + +
+ 主页 + + + \ No newline at end of file diff --git a/src/main/webapp/editComputer.jsp b/src/main/webapp/editComputer.jsp index f78f479..56425ce 100644 --- a/src/main/webapp/editComputer.jsp +++ b/src/main/webapp/editComputer.jsp @@ -3,23 +3,24 @@ + - Update Computer + 更新电脑信息 -

Update Computer

+

更新电脑信息

-
+


-
+


-
+


- +

- Back to List + 返回电脑列表 diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 4968a1f..a079096 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -4,13 +4,20 @@

电脑商城-首页

+

你好!${sessionScope.user.username}

- 电脑列表 - 用户列表 - 我的购物车 - 所有订单 + 电脑选购 + + 我的购物车 + 我的订单 + + + + 用户列表 + 所有订单 + 注销登录 - 我的订单 +

请登录后查看更多内容~

@@ -18,5 +25,7 @@ 注册 登录
+ + \ No newline at end of file diff --git a/src/main/webapp/myOrder.jsp b/src/main/webapp/myOrder.jsp index bf75da0..6a87ba6 100644 --- a/src/main/webapp/myOrder.jsp +++ b/src/main/webapp/myOrder.jsp @@ -3,6 +3,7 @@ + 我的订单 @@ -22,7 +23,6 @@ 总金额 地址 商品信息 - 操作 @@ -34,9 +34,6 @@ ${order.totalPrice} ${order.address} ${order.remark} - - 删除 - diff --git a/src/main/webapp/orders.jsp b/src/main/webapp/orders.jsp index caa1179..f5b59e6 100644 --- a/src/main/webapp/orders.jsp +++ b/src/main/webapp/orders.jsp @@ -3,6 +3,7 @@ + 订单列表 diff --git a/src/main/webapp/result.jsp b/src/main/webapp/result.jsp index ffcf44b..bfa40a7 100644 --- a/src/main/webapp/result.jsp +++ b/src/main/webapp/result.jsp @@ -3,6 +3,7 @@ + 操作结果 diff --git a/src/main/webapp/userList.jsp b/src/main/webapp/userList.jsp index 02c2fa7..1e1f8f2 100644 --- a/src/main/webapp/userList.jsp +++ b/src/main/webapp/userList.jsp @@ -3,12 +3,13 @@ + - user List + 系统用户 -

user List

+

系统用户

@@ -25,10 +26,9 @@ - +
${user.id} ${user.username} ${user.phone}${user.admin}${user.role} - Edit | - Delete + Delete