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

@@ -1,10 +1,10 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Model Binding Guide</title>
<title>模型绑定指南</title>
<style>
body { margin: 0; padding: 24px; font-family: "Aptos", "Segoe UI", sans-serif; background: linear-gradient(135deg, #7c3aed, #a855f7); }
.shell { max-width: 980px; 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); }
@@ -18,22 +18,22 @@
</head>
<body>
<div class="shell">
<div class="eyebrow">Guide</div>
<h1>Property binding vs model-driven binding</h1>
<p>This note helps explain how Struts2 turns request parameters into action state. It works well alongside the user form and validation examples.</p>
<div class="eyebrow">指南</div>
<h1>属性绑定与 ModelDriven 绑定怎么理解</h1>
<p>这页用来解释 Struts2 如何把请求参数装配进 Action。建议配合用户资料表单和字段校验实验一起看。</p>
<h2>Property-driven</h2>
<h2>属性驱动绑定</h2>
<ul>
<li>Define simple fields directly on the action.</li>
<li>Expose setters and getters for each form field.</li>
<li>Great for short demos and small forms.</li>
<li>直接在 Action 上定义简单字段。</li>
<li>为表单字段提供对应的 setter / getter</li>
<li>适合短流程 Demo 和小型表单。</li>
</ul>
<h2>Model-driven</h2>
<h2>ModelDriven 绑定</h2>
<ul>
<li>Return a dedicated model object from <code>getModel()</code>.</li>
<li>Keep request data separate from action orchestration logic.</li>
<li>Better for larger forms and nested objects.</li>
<li>通过 <code>getModel()</code> 返回一个独立模型对象。</li>
<li>把请求数据和 Action 编排逻辑拆开。</li>
<li>更适合复杂表单和嵌套对象。</li>
</ul>
<pre>public class UserAction extends ActionSupport implements ModelDriven&lt;User&gt; {
@@ -46,8 +46,8 @@
}</pre>
<div class="links">
<a class="btn" href="../../user/form.jsp">Open user form</a>
<a class="btn" href="../../index.jsp">Back to portal</a>
<a class="btn" href="../../userFormPage.action">打开用户表单实验</a>
<a class="btn" href="../../index.action">返回门户</a>
</div>
</div>
</body>