feat: expand struts demo lab

This commit is contained in:
Codex
2026-03-18 18:12:20 +08:00
parent 1f60832445
commit fba7b0497f
25 changed files with 1847 additions and 1447 deletions

View File

@@ -1,87 +1,117 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>文件上传 - Struts2 Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Upload Demo - Struts2 Demo Lab</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
body {
margin: 0;
min-height: 100vh;
padding: 20px;
padding: 24px;
font-family: "Aptos", "Segoe UI", "Microsoft YaHei", sans-serif;
background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 55%, #dff4ff 100%);
}
.container { max-width: 600px; margin: 0 auto; }
.card {
background: white;
padding: 30px;
border-radius: 15px;
box-shadow: 0 15px 50px rgba(0,0,0,0.3);
.shell {
max-width: 860px;
margin: 0 auto;
background: rgba(255,255,255,0.95);
border-radius: 28px;
padding: 28px;
box-shadow: 0 24px 60px rgba(0,0,0,0.18);
}
h2 { color: #4facfe; margin-bottom: 20px; }
.info {
background: #fff3e0;
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
border-left: 4px solid #ff9800;
.eyebrow {
font-size: 12px;
letter-spacing: 0.12em;
text-transform: uppercase;
color: #0284c7;
font-weight: 800;
}
.form-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 8px; color: #555; font-weight: 500; }
input[type="file"] {
width: 100%;
padding: 12px;
border: 2px dashed #4facfe;
border-radius: 8px;
background: #f0f9ff;
h1 { margin: 10px 0 12px; }
p { margin: 0; color: #54687c; line-height: 1.85; }
.note {
margin-top: 16px;
padding: 16px;
border-radius: 18px;
background: #eef8ff;
border: 1px solid #d6e9f7;
}
.field { margin-top: 16px; }
label { display: block; margin-bottom: 8px; font-weight: 700; color: #173652; }
input[type="file"] {
width: 100%;
padding: 16px;
border-radius: 16px;
border: 1px dashed #5ab8f0;
background: #f8fcff;
}
button {
width: 100%;
margin-top: 18px;
padding: 14px;
background: #4facfe;
border: 0;
border-radius: 14px;
background: linear-gradient(135deg, #0284c7, #38bdf8);
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 800;
cursor: pointer;
}
button:hover { background: #00c6fb; }
.action-error {
margin-top: 16px;
padding: 14px;
border-radius: 14px;
background: #fff1f1;
color: #b63a3a;
border: 1px solid #f1c4c4;
}
.links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.link-btn {
display: inline-flex;
padding: 10px 14px;
border-radius: 999px;
background: #edf7ff;
color: #0284c7;
text-decoration: none;
font-weight: 700;
}
</style>
</head>
<body>
<div class="container">
<div class="card">
<h2>📁 文件上传</h2>
<div class="info">
<strong>Struts2 文件上传原理:</strong>
<ul style="margin:10px 0 0 20px;">
<li>使用 <code>File</code> 类型接收文件</li>
<li>使用 <code>String fileName</code> 获取原始文件名</li>
<li>使用 <code>String contentType</code> 获取文件类型</li>
<li>底层使用 commons-fileupload</li>
</ul>
<div class="shell">
<div class="eyebrow">Upload demo</div>
<h1>Capture file metadata without writing anything to disk</h1>
<p>This safer upload sample focuses on how Struts binds multipart form fields. The action records metadata only, which makes the demo easier to run in constrained environments.</p>
<div class="note">
<strong>What the action collects</strong>
<p style="margin-top: 8px;">Primary filename, content type, and total selected file count.</p>
</div>
<s:if test="hasActionErrors()">
<div class="action-error"><s:actionerror/></div>
</s:if>
<s:form action="upload" method="post" enctype="multipart/form-data" namespace="/">
<div class="field">
<label>Primary file</label>
<s:file name="upload"/>
</div>
<s:form action="upload" method="post" enctype="multipart/form-data">
<div class="form-group">
<label>选择文件</label>
<s:file name="upload"/>
</div>
<div class="form-group">
<label>选择文件 (多文件)</label>
<s:file name="uploads" multiple="multiple"/>
</div>
<button type="submit">上传文件</button>
</s:form>
<p style="text-align:center;margin-top:20px;">
<a href="../index.jsp">← 返回首页</a>
</p>
<div class="field">
<label>Extra files</label>
<s:file name="uploads" multiple="multiple"/>
</div>
<button type="submit">Submit upload metadata</button>
</s:form>
<div class="links">
<a class="link-btn" href="../index.jsp">Back to portal</a>
<a class="link-btn" href="../demo/upload/index.jsp">Open upload guide</a>
</div>
</div>
</body>
</html>
</html>

View File

@@ -1,39 +1,92 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<title>操作成功</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Upload Summary - Struts2 Demo Lab</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
body {
margin: 0;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
font-family: "Aptos", "Segoe UI", "Microsoft YaHei", sans-serif;
background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 55%, #dff4ff 100%);
}
.card {
background: white;
padding: 40px;
border-radius: 15px;
text-align: center;
width: min(760px, 100%);
background: rgba(255,255,255,0.95);
border-radius: 28px;
padding: 28px;
box-shadow: 0 24px 60px rgba(0,0,0,0.18);
}
h1 { color: #11998e; }
.btn {
display: inline-block;
margin-top: 20px;
padding: 12px 30px;
background: #11998e;
color: white;
.eyebrow {
font-size: 12px;
letter-spacing: 0.12em;
text-transform: uppercase;
color: #0284c7;
font-weight: 800;
}
h1 { margin: 10px 0 12px; }
p { margin: 0; color: #53677b; line-height: 1.85; }
.stats {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px;
margin-top: 18px;
}
.stat {
padding: 16px;
border-radius: 18px;
background: #f5fbff;
border: 1px solid #d8ebf8;
}
.stat span { display: block; font-size: 12px; color: #62809d; margin-bottom: 6px; }
.stat strong { font-size: 20px; }
.links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.link-btn {
display: inline-flex;
padding: 10px 14px;
border-radius: 999px;
background: #edf7ff;
color: #0284c7;
text-decoration: none;
border-radius: 25px;
font-weight: 700;
}
@media (max-width: 720px) {
.stats { grid-template-columns: 1fr; }
}
</style>
</head>
<body>
<div class="card">
<h1>✅ 操作成功!</h1>
<a href="../../index.jsp" class="btn">返回首页</a>
<div class="eyebrow">Upload summary</div>
<h1>Upload metadata captured successfully</h1>
<p><s:property value="summary" default="The demo collected upload metadata without persisting files."/></p>
<div class="stats">
<div class="stat">
<span>Selected files</span>
<strong><s:property value="fileCount" default="0"/></strong>
</div>
<div class="stat">
<span>Primary filename</span>
<strong><s:property value="uploadFileName" default="Not provided"/></strong>
</div>
<div class="stat">
<span>Content type</span>
<strong><s:property value="uploadContentType" default="Unknown"/></strong>
</div>
</div>
<div class="links">
<a class="link-btn" href="index.jsp">Try another upload</a>
<a class="link-btn" href="../index.jsp">Back to portal</a>
</div>
</div>
</body>
</html>
</html>