forked from admin/struts2-demo
87 lines
2.8 KiB
Plaintext
87 lines
2.8 KiB
Plaintext
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
|
<%@ taglib prefix="s" uri="/struts-tags" %>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>文件上传 - Struts2 Demo</title>
|
|
<style>
|
|
body {
|
|
font-family: 'Segoe UI', sans-serif;
|
|
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
|
|
min-height: 100vh;
|
|
padding: 20px;
|
|
}
|
|
.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);
|
|
}
|
|
h2 { color: #4facfe; margin-bottom: 20px; }
|
|
.info {
|
|
background: #fff3e0;
|
|
padding: 15px;
|
|
border-radius: 8px;
|
|
margin-bottom: 20px;
|
|
border-left: 4px solid #ff9800;
|
|
}
|
|
.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;
|
|
}
|
|
button {
|
|
width: 100%;
|
|
padding: 14px;
|
|
background: #4facfe;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-size: 16px;
|
|
cursor: pointer;
|
|
}
|
|
button:hover { background: #00c6fb; }
|
|
</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>
|
|
|
|
<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>
|
|
</div>
|
|
</body>
|
|
</html> |