diff --git a/project/.gitignore b/project/.gitignore index 5ff6309..c63f993 100644 --- a/project/.gitignore +++ b/project/.gitignore @@ -35,4 +35,7 @@ build/ .vscode/ ### Mac OS ### -.DS_Store \ No newline at end of file +.DS_Store + +### out ### +out/ \ No newline at end of file diff --git a/project/pom.xml b/project/pom.xml index 7201e21..1ad02c6 100644 --- a/project/pom.xml +++ b/project/pom.xml @@ -76,5 +76,10 @@ 2.20.0 + + commons-dbcp + commons-dbcp + 1.4 + \ No newline at end of file diff --git a/project/src/main/java/cyou/chenx221/controller/AdminController.java b/project/src/main/java/cyou/chenx221/controller/AdminController.java index 10bd58d..6c837e0 100644 --- a/project/src/main/java/cyou/chenx221/controller/AdminController.java +++ b/project/src/main/java/cyou/chenx221/controller/AdminController.java @@ -12,33 +12,29 @@ import org.springframework.web.bind.annotation.RequestParam; @RequestMapping("/admin") public class AdminController { - private final AdminService adminService; - @Autowired - public AdminController(AdminService adminService) { - this.adminService = adminService; - } - - @GetMapping("/login") - public String showLoginForm() { - return "admin-login-form"; - } + private AdminService adminService; @PostMapping("/login") - public String login(@RequestParam("username") String username, @RequestParam("password") String password) { - boolean isValid = adminService.validateCredentials(username, password); - if (isValid) { - // 登录成功,重定向到管理页面 + public String login(@RequestParam("username") String username, + @RequestParam("password") String password) { + + // 进行用户名和密码的验证逻辑 + if (adminService.validateCredentials(username, password)) { + // 验证成功,进行相应的操作 + // 这里可以进行重定向或返回视图等操作 return "redirect:/admin/dashboard"; } else { - // 登录失败,返回登录页面并显示错误消息 + // 验证失败,返回登录页面或错误提示 return "redirect:/admin/login?error"; } } @GetMapping("/dashboard") - public String showDashboard() { - return "admin-dashboard"; + public String dashboard() { + // 处理管理员登录后的仪表盘页面 + // 返回相应的视图页面 + return "admin/dashboard"; } @GetMapping("/logout") diff --git a/project/src/main/java/cyou/chenx221/service/impl/AdminServiceImpl.java b/project/src/main/java/cyou/chenx221/service/impl/AdminServiceImpl.java index ffd82af..c27ca38 100644 --- a/project/src/main/java/cyou/chenx221/service/impl/AdminServiceImpl.java +++ b/project/src/main/java/cyou/chenx221/service/impl/AdminServiceImpl.java @@ -18,6 +18,7 @@ public class AdminServiceImpl implements AdminService { this.adminDao = adminDao; } + @Override public void addAdmin(Admin admin) { adminDao.addAdmin(admin); diff --git a/project/src/main/java/cyou/chenx221/servlet/AdminServlet.java b/project/src/main/java/cyou/chenx221/servlet/AdminServlet.java index 6324f5f..a5f16dd 100644 --- a/project/src/main/java/cyou/chenx221/servlet/AdminServlet.java +++ b/project/src/main/java/cyou/chenx221/servlet/AdminServlet.java @@ -1,4 +1,43 @@ package cyou.chenx221.servlet; -public class AdminServlet { +import cyou.chenx221.service.AdminService; +import cyou.chenx221.service.impl.AdminServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; + +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; +import java.io.PrintWriter; + +@WebServlet("/admin") +public class AdminServlet extends HttpServlet { + + @Autowired + private AdminService adminService; + + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + String username = request.getParameter("username"); + String password = request.getParameter("password"); + + // 调用 AdminService 的验证凭证方法进行验证 + boolean isValidCredentials = adminService.validateCredentials(username, password); + + if (isValidCredentials) { + // 登录成功,设置会话状态 + request.getSession().setAttribute("isLoggedIn", true); + response.sendRedirect("dashboard.jsp"); // 重定向到仪表盘页面 + } else { + // 登录失败,返回错误消息 + response.setContentType("text/html"); + PrintWriter out = response.getWriter(); + out.println(""); + out.println("

登录失败,用户名或密码不正确。

"); + out.println(""); + } + } } diff --git a/project/src/main/resources/applicationContext.xml b/project/src/main/resources/applicationContext.xml new file mode 100644 index 0000000..b967a0f --- /dev/null +++ b/project/src/main/resources/applicationContext.xml @@ -0,0 +1,40 @@ + + + + + + classpath:db.properties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/project/src/main/resources/mybatis-config.xml b/project/src/main/resources/mybatis-config.xml index afd5400..92988ca 100644 --- a/project/src/main/resources/mybatis-config.xml +++ b/project/src/main/resources/mybatis-config.xml @@ -16,6 +16,8 @@ - + + + diff --git a/project/web/img/jason-blackeye-nyL-rzwP-Mk-unsplash.jpg b/project/web/img/jason-blackeye-nyL-rzwP-Mk-unsplash.jpg new file mode 100644 index 0000000..e8ac550 Binary files /dev/null and b/project/web/img/jason-blackeye-nyL-rzwP-Mk-unsplash.jpg differ diff --git a/project/web/img/mdb-favicon.ico b/project/web/img/mdb-favicon.ico deleted file mode 100644 index fe7721d..0000000 Binary files a/project/web/img/mdb-favicon.ico and /dev/null differ diff --git a/project/web/login.html b/project/web/login.html index d79c44a..a4e2e92 100644 --- a/project/web/login.html +++ b/project/web/login.html @@ -12,10 +12,108 @@ rel="stylesheet"> - -
-
+ + +
+ +
+ +
+
+
+
+
+
+
+

用户登录

+
+ + +
+
+ + +
+
+
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+ + + + + + +
+ + diff --git a/project/web/template.html b/project/web/template.html index d79c44a..5ae7f5c 100644 --- a/project/web/template.html +++ b/project/web/template.html @@ -13,9 +13,25 @@ -
+ +
-
+ + + + +
+
+ +
+
+ + + + + diff --git a/project/web/test/test1.html b/project/web/test/test1.html new file mode 100644 index 0000000..b853700 --- /dev/null +++ b/project/web/test/test1.html @@ -0,0 +1,648 @@ + + + + + + + 登录 + + + + + + + + +
+ +
+ + + + + + + +
+ +
+ +
+
+

Whoah, what a view!

+
Learning web design is such an amazing thing
+ Learn with me +
+
+ +
+ + +
+
+
+ + + +
+
+ +
+
+ + + +
+
+
+ + + +
+ +
+ +

Details

+ +

This beginner-friendly, example-based course will guide you through the essential + knowledge of MDB + ecosystem.

+ +

What will you learn:

+ +
    +
  • Bootstrap
  • +
  • MDBootstrap
  • +
  • UI & UX design
  • +
  • Responsive web design
  • +
+ + Learn more + +
+
+
+ + +
+ +

Pricing

+ +
+
+ +
+
+

+ Basic +

+ +

+ $ 129 + /year +

+ + + +
+
+ +
    +
  1. + Unlimited + updates +
  2. +
  3. + Git repository +
  4. +
  5. + npm + installation +
  6. +
+ +
+
+ +
+ +
+ +
+
+

+ Advanced +

+ +

+ $ 299 + /year +

+ + +
+
+
    +
  1. + Unlimited + updates +
  2. +
  3. + Git repository +
  4. +
  5. + npm + installation +
  6. +
  7. + Code examples +
  8. +
  9. + Premium + snippets +
  10. +
+
+
+ +
+ +
+ +
+
+

+ Enterprise +

+

+ $ 499 + /year +

+ + +
+
+
    +
  1. + Unlimited + updates +
  2. +
  3. + Git repository +
  4. +
  5. + npm + installation +
  6. +
  7. + Code examples +
  8. +
  9. + Premium + snippets +
  10. +
  11. + Premium + support +
  12. +
  13. + Drag&Drop + builder +
  14. +
+
+
+ +
+
+ +
+ + +
+ +

Contact us

+ +
+ +
+ +
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + +
+ +
+ +
+ +
+
+
+
+ +
+
+

Technical support

+

support@example.com

+

+1 234-567-89

+
+
+
+ +
+
+
+ +
+
+

Sales questions

+

sales@example.com

+

+1 234-567-88

+
+
+
+ +
+
+
+ +
+
+

Press

+

press@example.com

+

+1 234-567-87

+
+
+
+ +
+
+
+ +
+
+

Bug report

+

bugs@example.com

+

+1 234-567-86

+
+
+
+
+ +
+
+ +
+ +
+
+ +
+
+ + + + + + + + + + diff --git a/project/web/test/test2.html b/project/web/test/test2.html new file mode 100644 index 0000000..3a70462 --- /dev/null +++ b/project/web/test/test2.html @@ -0,0 +1,926 @@ + + + + + + + 登录 + + + + + + + + + + +
+ + + + +
+ +
+
+ + +
+ + +
+
+

John Doe

+

Web developer

+
+
+ + +
+ +
+ See my projects +
+ +
+ + + +
+ +
+ + +
+
+ +
+ + +
+ + + +
+
+ + +
+

My projects

+ +
+ + +
+ +
+
+ + + +
+
+ +
+
+
AI engine
+

+ Finished 13.09.2021 for + Techify +

+

+ Ut pretium ultricies dignissim. Sed sit amet mi eget urna + placerat vulputate. Ut vulputate est non quam dignissim + elementum. Donec a ullamcorper diam. +

+ Read more +
+
+ +
+ + + +
+ +
+
+ + +
+
+
+
+
Balanced design
+

+ Finished 12.01.2022 for + Rubicon +

+

+ Suspendisse in volutpat massa. Nulla facilisi. Sed aliquet + diam orci, nec ornare metus semper sed. Integer volutpat + ornare erat sit amet rutrum. Ut vulputate est non quam. +

+ Read more +
+
+ +
+ + + +
+ +
+
+ + +
+
+
+
+
Metaverse 2.0
+

+ Finished 10.11.2022 for + Venom Tech +

+

+ Curabitur tristique, mi a mollis sagittis, metus felis mattis + arcu, non vehicula nisl dui quis diam. Mauris ut risus eget + massa volutpat feugiat. Donec. +

+ Read more +
+
+ +
+ + +
+ +
+ + +
+ + + + + + + + + + +
+ + +
+ +
+ +
+ + +
+ +
+
+

+ John Doe +

+

“Design is intelligence made visible.”

+ +

+ Nunc tincidunt vulputate elit. Mauris varius purus malesuada + neque iaculis malesuada. Aenean gravida magna orci, non + efficitur est porta id. Donec magna diam. +

+

+ Ad, at blanditiis quaerat laborum officia incidunt + cupiditate dignissimos voluptates eius aliquid minus + praesentium! Perferendis et totam ipsum ex aut earum libero + accusamus voluptas quod numquam saepe, consequuntur nihil + quia tenetur consequatur. Quis, explicabo deserunt quasi + assumenda ea maiores nulla, et dolor saepe praesentium natus + error reiciendis voluptas iste. Esse, laudantium ipsum + animi, quos voluptatibus atque vero repellat sit eligendi + autem maiores quasi cum aperiam. Aperiam rerum culpa + accusantium, ducimus deserunt aliquid alias vitae quasi + corporis placeat vel maiores explicabo commodi! +

+
+
+ +
+ + + +
+
+ +
+
+
+ + +
+ +
+ +
+ + +
+ +

Happy clients

+ +
+ + +
+ +
+
+ +
+

Project Manager at Spotify

+

Garry Lindman

+

+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Facilis molestias quidem + itaque earum tempora distinctio soluta ut, eius, impedit porro iure praesentium + ratione possimus quos suscipit, ratione nostrum cum odit. +

+
+ Avatar +
+ +
+ + + +
+ +
+
+ +
+

CEO at Reddit

+

Lisa Montessori

+

+ Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum + soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime + placeat facere possimus, omnis voluptas assumenda est omnis. +

+
+ Avatar +
+ +
+ + + +
+ +
+
+ +
+

Senior Product Designer at Twitter

+

Ozzy McRyan

+

+ Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe + eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque + earum rerum hic tenetur a sapiente delectus ut aut reiciendis. +

+
+ Avatar +
+ +
+ + +
+
+ + +
+ +
+ +
+ + +
+ +
+
+
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + +
+
+
+ +
+ + + +
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
+ + + + + + + + + + + +