Files
struts2-demo/web/WEB-INF/views/upload/index.jsp

130 lines
4.5 KiB
Plaintext
Raw Normal View History

2026-03-18 15:18:30 +08:00
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html lang="zh-CN">
2026-03-18 15:18:30 +08:00
<head>
<meta charset="UTF-8">
2026-03-18 18:12:20 +08:00
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>上传元数据实验 - Struts2 学习实验台</title>
2026-03-18 15:18:30 +08:00
<style>
2026-03-18 18:12:20 +08:00
body {
margin: 0;
2026-03-18 15:18:30 +08:00
min-height: 100vh;
2026-03-18 18:12:20 +08:00
padding: 24px;
font-family: "Aptos", "Segoe UI", "Microsoft YaHei", sans-serif;
background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 55%, #dff4ff 100%);
2026-03-18 15:18:30 +08:00
}
2026-03-18 18:12:20 +08:00
.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);
2026-03-18 15:18:30 +08:00
}
2026-03-18 18:12:20 +08:00
.eyebrow {
font-size: 12px;
letter-spacing: 0.12em;
text-transform: uppercase;
color: #0284c7;
font-weight: 800;
2026-03-18 15:18:30 +08:00
}
2026-03-18 18:12:20 +08:00
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;
2026-03-18 15:18:30 +08:00
}
button {
width: 100%;
2026-03-18 18:12:20 +08:00
margin-top: 18px;
2026-03-18 15:18:30 +08:00
padding: 14px;
2026-03-18 18:12:20 +08:00
border: 0;
border-radius: 14px;
background: linear-gradient(135deg, #0284c7, #38bdf8);
2026-03-18 15:18:30 +08:00
color: white;
font-size: 16px;
2026-03-18 18:12:20 +08:00
font-weight: 800;
2026-03-18 15:18:30 +08:00
cursor: pointer;
}
2026-03-18 18:12:20 +08:00
.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;
}
2026-03-18 15:18:30 +08:00
</style>
</head>
<body>
2026-03-18 18:12:20 +08:00
<div class="shell">
<div class="eyebrow">受保护上传页</div>
<h1>只采集上传元数据,不把文件真正落盘</h1>
<p>这个页面保留了 multipart 表单绑定的教学意义但避免真实写盘更适合本地、VPS 和课堂演示环境。</p>
2026-03-18 18:12:20 +08:00
<s:if test="#session.demoUser == null">
<div class="note">
<strong>当前未登录</strong>
<p style="margin-top: 8px;">上传页也已经接入 Session 保护。请先登录,再看 Struts2 对文件字段和元数据的绑定结果。</p>
</div>
<div class="links">
<a class="link-btn" href="../loginPage.action">先去登录</a>
<a class="link-btn" href="../index.action">返回门户</a>
</div>
2026-03-18 18:12:20 +08:00
</s:if>
<s:else>
<div class="note">
<strong>这一页采集什么</strong>
<p style="margin-top: 8px;">主文件名、内容类型和总文件数量。不会真实保存上传文件。</p>
2026-03-18 18:12:20 +08:00
</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>主文件</label>
<s:file name="upload"/>
</div>
2026-03-18 18:12:20 +08:00
<div class="field">
<label>附加文件</label>
<s:file name="uploads" multiple="multiple"/>
</div>
2026-03-18 18:12:20 +08:00
<button type="submit">提交并查看上传元数据</button>
</s:form>
<div class="links">
<a class="link-btn" href="../dashboard.action">返回仪表盘</a>
<a class="link-btn" href="../index.action">回到门户</a>
</div>
</s:else>
2026-03-18 15:18:30 +08:00
</div>
</body>
2026-03-18 18:12:20 +08:00
</html>