feat: expand struts demo lab
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user