Files
struts2-demo/web/upload/index.jsp
2026-03-18 18:12:20 +08:00

118 lines
3.8 KiB
Plaintext

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Upload Demo - Struts2 Demo Lab</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">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>
<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>