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

130 lines
4.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<%@ 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, #0ea5e9 0%, #38bdf8 55%, #dff4ff 100%);
}
.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);
}
.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: #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;
border: 0;
border-radius: 14px;
background: linear-gradient(135deg, #0284c7, #38bdf8);
color: white;
font-size: 16px;
font-weight: 800;
cursor: pointer;
}
.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="shell">
<div class="eyebrow">受保护上传页</div>
<h1>只采集上传元数据,不把文件真正落盘</h1>
<p>这个页面保留了 multipart 表单绑定的教学意义但避免真实写盘更适合本地、VPS 和课堂演示环境。</p>
<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>
</s:if>
<s:else>
<div class="note">
<strong>这一页采集什么</strong>
<p style="margin-top: 8px;">主文件名、内容类型和总文件数量。不会真实保存上传文件。</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>主文件</label>
<s:file name="upload"/>
</div>
<div class="field">
<label>附加文件</label>
<s:file name="uploads" multiple="multiple"/>
</div>
<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>
</div>
</body>
</html>