feat: finish bilingual session auth learning lab

This commit is contained in:
Codex
2026-03-24 09:18:13 +08:00
parent 4cc4c26f2b
commit 5e318cb7f4
27 changed files with 1911 additions and 1079 deletions

View File

@@ -0,0 +1,126 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>用户资料表单 - Struts2 学习实验台</title>
<style>
body {
margin: 0;
min-height: 100vh;
padding: 24px;
font-family: "Aptos", "Segoe UI", "Microsoft YaHei", sans-serif;
background: linear-gradient(135deg, #f97316 0%, #fb923c 50%, #ffedd5 100%);
}
.shell {
max-width: 880px;
margin: 0 auto;
background: rgba(255,255,255,0.96);
border-radius: 28px;
padding: 28px;
box-shadow: 0 24px 60px rgba(0,0,0,0.18);
}
.eyebrow {
font-size: 12px;
letter-spacing: 0.12em;
text-transform: uppercase;
color: #ea580c;
font-weight: 800;
}
h1 { margin: 10px 0 12px; }
p { margin: 0; color: #6c5545; line-height: 1.85; }
.field { margin-top: 16px; }
label { display: block; margin-bottom: 8px; font-weight: 700; color: #4c3422; }
input {
width: 100%;
padding: 13px 14px;
border-radius: 14px;
border: 1px solid #ead8ca;
font: inherit;
}
button {
width: 100%;
margin-top: 18px;
padding: 14px;
border: 0;
border-radius: 14px;
background: linear-gradient(135deg, #ea580c, #fb923c);
color: white;
font-size: 16px;
font-weight: 800;
cursor: pointer;
}
.error { color: #c2410c; font-size: 13px; margin-top: 6px; }
.note {
margin-top: 18px;
padding: 16px;
border-radius: 18px;
background: #fff5ef;
border: 1px solid #f2d9ca;
}
.links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.link-btn {
display: inline-flex;
padding: 10px 14px;
border-radius: 999px;
background: #fff1e8;
color: #c2410c;
text-decoration: none;
font-weight: 700;
}
</style>
</head>
<body>
<div class="shell">
<div class="eyebrow">受保护表单</div>
<h1>通过 Action 属性绑定提交一份用户资料</h1>
<p>这个页面现在放在登录保护链路里。重点不是字段本身,而是观察请求参数如何进入 Action再在成功页汇总成一份结构化结果。</p>
<s:if test="#session.demoUser == null">
<div class="note">
<strong>当前未登录</strong>
<p style="margin-top: 8px;">这个实验页已经接入 Session 保护。请先登录,再回来看字段绑定和错误回显。</p>
</div>
<div class="links">
<a class="link-btn" href="../loginPage.action">先去登录</a>
<a class="link-btn" href="../index.action">返回门户</a>
</div>
</s:if>
<s:else>
<div class="note">
<strong>建议观察点</strong>
<p style="margin-top: 8px;">依次观察:字段名如何对应 Action 属性、校验错误如何回显、成功页如何读取 Action 结果。</p>
</div>
<s:form action="submitUser" method="post" namespace="/">
<div class="field">
<label for="username">用户名</label>
<s:textfield id="username" name="username" placeholder="platform-owner"/>
<div class="error"><s:fielderror fieldName="username"/></div>
</div>
<div class="field">
<label for="email">邮箱</label>
<s:textfield id="email" name="email" placeholder="platform@example.com"/>
<div class="error"><s:fielderror fieldName="email"/></div>
</div>
<div class="field">
<label for="phone">手机号</label>
<s:textfield id="phone" name="phone" placeholder="13800000000"/>
<div class="error"><s:fielderror fieldName="phone"/></div>
</div>
<button type="submit">提交资料并生成汇总页</button>
</s:form>
<div class="links">
<a class="link-btn" href="../dashboard.action">返回仪表盘</a>
<a class="link-btn" href="../validationPage.action">下一步看校验页</a>
</div>
</s:else>
</div>
</body>
</html>