59 lines
2.3 KiB
Plaintext
59 lines
2.3 KiB
Plaintext
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
|
<%@ taglib prefix="s" uri="/struts-tags" %>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>用户管理 - Struts2 CRUD 示例</title>
|
|
<style>
|
|
body { font-family: Arial, sans-serif; max-width: 800px; margin: 50px auto; padding: 20px; }
|
|
h1 { color: #e74c3c; }
|
|
table { width: 100%; border-collapse: collapse; margin: 20px 0; }
|
|
th, td { border: 1px solid #ddd; padding: 12px; text-align: left; }
|
|
th { background: #3498db; color: white; }
|
|
tr:nth-child(even) { background: #f9f9f9; }
|
|
.btn { padding: 5px 10px; text-decoration: none; border-radius: 3px; margin-right: 5px; }
|
|
.btn-edit { background: #f39c12; color: white; }
|
|
.btn-delete { background: #e74c3c; color: white; }
|
|
.btn-add { background: #2ecc71; color: white; padding: 10px 20px; }
|
|
.tip { background: #f9f9f9; padding: 15px; border-left: 4px solid #3498db; margin: 20px 0; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>👥 用户管理 - Struts2 CRUD 示例</h1>
|
|
|
|
<p><a class="btn btn-add" href="user_edit">+ 添加用户</a></p>
|
|
|
|
<table>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>姓名</th>
|
|
<th>邮箱</th>
|
|
<th>年龄</th>
|
|
<th>操作</th>
|
|
</tr>
|
|
<s:iterator value="userList" var="u">
|
|
<tr>
|
|
<td><s:property value="#u.id"/></td>
|
|
<td><s:property value="#u.name"/></td>
|
|
<td><s:property value="#u.email"/></td>
|
|
<td><s:property value="#u.age"/></td>
|
|
<td>
|
|
<a class="btn btn-edit" href="user_edit?id=<s:property value='#u.id'/>">编辑</a>
|
|
<a class="btn btn-delete" href="user_delete?id=<s:property value='#u.id'/>" onclick="return confirm('确定删除?')">删除</a>
|
|
</td>
|
|
</tr>
|
|
</s:iterator>
|
|
</table>
|
|
|
|
<div class="tip">
|
|
<strong>学习点:</strong>
|
|
<ul>
|
|
<li><code><s:iterator></code> 遍历集合</li>
|
|
<li><code>redirectAction</code> 结果类型实现 PRG 模式</li>
|
|
<li>动态方法调用处理不同操作</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<p><a href="learn">← 返回学习中心</a></p>
|
|
</body>
|
|
</html> |