diff --git a/src/com/landaiqing/dao/AdminUserDao.java b/src/com/landaiqing/dao/AdminUserDao.java index 6b68816..5e7cb1d 100644 --- a/src/com/landaiqing/dao/AdminUserDao.java +++ b/src/com/landaiqing/dao/AdminUserDao.java @@ -6,6 +6,7 @@ import com.landaiqing.utils.JdbcUtils; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.util.ArrayList; public class AdminUserDao { private AdminUserEntity adminUserEntity=new AdminUserEntity(); @@ -39,4 +40,32 @@ public class AdminUserDao { JdbcUtils.closeConnection(resultSet, preparedStatement, connection); } } + /** + * 查询所有管理员 + * */ + public ArrayList selectAllAdmin() { + ResultSet resultSet = null; + PreparedStatement preparedStatement = null; + Connection connection = null; + try { + connection = JdbcUtils.getConnection(); + String loginSql = "select * from admin;"; + preparedStatement = connection.prepareStatement(loginSql); + resultSet = preparedStatement.executeQuery(); + ArrayList adminUserDaos=new ArrayList<>(); + while (resultSet.next()) { + Integer id = resultSet.getInt(1); + String dbUserName = resultSet.getString(2); + String dbUserPwd = resultSet.getString(3); + AdminUserEntity adminUserEntity = new AdminUserEntity(id,dbUserName, dbUserPwd); + adminUserDaos.add(adminUserEntity); + } + return adminUserDaos; + } catch (Exception e) { + e.printStackTrace(); + return null; + } finally { + JdbcUtils.closeConnection(resultSet, preparedStatement, connection); + } + } } diff --git a/src/com/landaiqing/filter/UserSessionFilter.java b/src/com/landaiqing/filter/UserSessionFilter.java index 81b4145..4506a6b 100644 --- a/src/com/landaiqing/filter/UserSessionFilter.java +++ b/src/com/landaiqing/filter/UserSessionFilter.java @@ -14,7 +14,7 @@ import java.io.IOException; */ @WebFilter("/System/*")// 过滤器所有的请求 public class UserSessionFilter implements Filter { - private String[] excludeUrls = new String[]{"/login", "/register", "/VerifycodeServlet"}; + private String[] excludeUrls = new String[]{"/login", "/publish","/reply","/VerifycodeServlet"}; @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { @@ -38,7 +38,7 @@ public class UserSessionFilter implements Filter { if (user == null) { // 当前用户没有登录或者登录会话失效 // 重定向到登录页面 - httpServletResponse.sendRedirect(contextPath+"/login"); + httpServletResponse.sendRedirect(contextPath+"/"); return; } // 用户已经登录了 正常放行请求 diff --git a/src/com/landaiqing/service/AdminUserService.java b/src/com/landaiqing/service/AdminUserService.java index bc54883..d808d99 100644 --- a/src/com/landaiqing/service/AdminUserService.java +++ b/src/com/landaiqing/service/AdminUserService.java @@ -3,6 +3,8 @@ package com.landaiqing.service; import com.landaiqing.dao.AdminUserDao; import com.landaiqing.entity.AdminUserEntity; +import java.util.ArrayList; + public class AdminUserService { private AdminUserDao adminUserDao=new AdminUserDao(); @@ -12,4 +14,11 @@ public class AdminUserService { public AdminUserEntity login(String userName, String userPwd) { return adminUserDao.login(userName,userPwd); } + + /** + * 查询所有管理员 + * */ + public ArrayList selectAllAdmin() { + return adminUserDao.selectAllAdmin(); + } } diff --git a/src/com/landaiqing/servlet/system/AllAdmin.java b/src/com/landaiqing/servlet/system/AllAdmin.java new file mode 100644 index 0000000..6988043 --- /dev/null +++ b/src/com/landaiqing/servlet/system/AllAdmin.java @@ -0,0 +1,30 @@ +package com.landaiqing.servlet.system; + +import com.landaiqing.entity.AdminUserEntity; +import com.landaiqing.service.AdminUserService; +import jakarta.servlet.ServletException; +import jakarta.servlet.annotation.WebServlet; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +@WebServlet("/allAdmin") +public class AllAdmin extends HttpServlet { + private AdminUserService adminUserService=new AdminUserService(); + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + doPost(req,resp); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + List adminUserEntityList=adminUserService.selectAllAdmin(); + req.setAttribute("allAdmin",adminUserEntityList); + req.getRequestDispatcher("./System/index.jsp").forward(req,resp); + + } +} diff --git a/web/System/adminManage.jsp b/web/System/adminManage.jsp new file mode 100644 index 0000000..b048758 --- /dev/null +++ b/web/System/adminManage.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: LDQ + Date: 2023/6/9 + Time: 16:57 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Title + + + 管理员管理 + + diff --git a/web/System/index.jsp b/web/System/index.jsp index d2fa33e..bf333e4 100644 --- a/web/System/index.jsp +++ b/web/System/index.jsp @@ -12,6 +12,9 @@ + + + @@ -22,119 +25,301 @@
- - - +
-
- + + + +
+ + +
+ +
-
-
- Layui 框体布局内容主体区域 -
-
-
- 下面是充数内容,为的是出现滚动条 -
-
- 充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
充数内容
你还真滑到了底部呀 -
+
+ +
    +
+ + + + + +
+
-

+
+ + +
- + diff --git a/web/System/messageManage.jsp b/web/System/messageManage.jsp new file mode 100644 index 0000000..b80ff9f --- /dev/null +++ b/web/System/messageManage.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: LDQ + Date: 2023/6/9 + Time: 16:57 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Title + + +留言管理 + +