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 @@
+ -ID | -Name | -Price | -Stock | -Actions | -
---|---|---|---|---|
${computer.id} | -${computer.name} | -${computer.price} | -${computer.stock} | -- Edit | - Delete | - 加购 - | -
${requestScope.msg}
- 我的购物车 -ID | +名称 | +价格 | +库存 | +操作 | +
---|---|---|---|---|
${computer.id} | +${computer.name} | +${computer.price} | +${computer.stock} | +
+ |
+
${requestScope.msg}
+ +你好!${sessionScope.user.username}
请登录后查看更多内容~
@@ -18,5 +25,7 @@ 注册 登录${user.id} | ${user.username} | ${user.phone} | -${user.admin} | +${user.role} | - Edit | - Delete + Delete |