| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <%@ page import="space.anyi.studentManageSystem_JSP.model.Student" %>
- <%@ page import="java.util.List" %>
- <html>
- <head>
- <title>学生管理系统 - 学生列表</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- margin: 0;
- padding: 0;
- background-color: #f5f5f5;
- }
- .header {
- background-color: #007bff;
- color: white;
- padding: 20px;
- text-align: center;
- }
- .container {
- max-width: 1200px;
- margin: 20px auto;
- padding: 20px;
- background-color: white;
- border-radius: 8px;
- box-shadow: 0 2px 10px rgba(0,0,0,0.1);
- }
- .search-form {
- margin-bottom: 20px;
- display: flex;
- gap: 10px;
- }
- .search-form input {
- flex: 1;
- padding: 8px;
- border: 1px solid #ddd;
- border-radius: 4px;
- }
- .btn {
- padding: 8px 16px;
- border: none;
- border-radius: 4px;
- cursor: pointer;
- text-decoration: none;
- display: inline-block;
- text-align: center;
- }
- .btn-primary {
- background-color: #007bff;
- color: white;
- }
- .btn-success {
- background-color: #28a745;
- color: white;
- }
- .btn-warning {
- background-color: #ffc107;
- color: black;
- }
- .btn-danger {
- background-color: #dc3545;
- color: white;
- }
- .btn:hover {
- opacity: 0.8;
- }
- .message {
- padding: 10px;
- margin-bottom: 20px;
- border-radius: 4px;
- text-align: center;
- }
- .success {
- background-color: #d4edda;
- color: #155724;
- border: 1px solid #c3e6cb;
- }
- .error {
- background-color: #f8d7da;
- color: #721c24;
- border: 1px solid #f5c6cb;
- }
- table {
- width: 100%;
- border-collapse: collapse;
- margin-top: 20px;
- }
- table th, table td {
- padding: 12px;
- text-align: left;
- border-bottom: 1px solid #ddd;
- }
- table th {
- background-color: #f8f9fa;
- font-weight: bold;
- }
- .actions {
- display: flex;
- gap: 5px;
- }
- .no-data {
- text-align: center;
- padding: 40px;
- color: #666;
- }
- </style>
- </head>
- <body>
- <div class="header">
- <h1>学生管理系统</h1>
- <div>
- <a href="${pageContext.request.contextPath}/student?action=add" class="btn btn-success">添加学生</a>
- <a href="${pageContext.request.contextPath}/logout" class="btn btn-danger" style="margin-left: 10px;">退出登录</a>
- </div>
- </div>
- <div class="container">
- <% if (request.getAttribute("message") != null) { %>
- <div class="message success">
- <%= request.getAttribute("message") %>
- </div>
- <% } %>
- <form class="search-form" action="${pageContext.request.contextPath}/student" method="get">
- <input type="hidden" name="action" value="search">
- <input type="text" name="name" placeholder="请输入学生姓名"
- value="<%= request.getAttribute("searchName") != null ? request.getAttribute("searchName") : "" %>">
- <button type="submit" class="btn btn-primary">搜索</button>
- <a href="${pageContext.request.contextPath}/student?action=list" class="btn">显示全部</a>
- </form>
- <%
- List<Student> students = (List<Student>) request.getAttribute("students");
- if (students != null && !students.isEmpty()) {
- %>
- <table>
- <thead>
- <tr>
- <th>ID</th>
- <th>姓名</th>
- <th>学号</th>
- <th>班级</th>
- <th>宿舍号</th>
- <th>联系方式</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody>
- <% for (Student student : students) { %>
- <tr>
- <td><%= student.getId() %></td>
- <td><%= student.getName() %></td>
- <td><%= student.getStudentId() %></td>
- <td><%= student.getClassName() %></td>
- <td><%= student.getDormitoryNumber() != null ? student.getDormitoryNumber() : "-" %></td>
- <td><%= student.getContact() != null ? student.getContact() : "-" %></td>
- <td class="actions">
- <a href="${pageContext.request.contextPath}/student?action=edit&id=<%= student.getId() %>"
- class="btn btn-warning">编辑</a>
- <a href="${pageContext.request.contextPath}/student?action=delete&id=<%= student.getId() %>"
- class="btn btn-danger"
- onclick="return confirm('确定要删除学生 <%= student.getName() %> 吗?')">删除</a>
- </td>
- </tr>
- <% } %>
- </tbody>
- </table>
- <% } else { %>
- <div class="no-data">
- <h3>暂无学生数据</h3>
- <p>点击"添加学生"按钮来添加第一条学生记录</p>
- </div>
- <% } %>
- </div>
- </body>
- </html>
|