Files
struts2-demo/web/user/login.jsp
2026-03-18 15:18:30 +08:00

94 lines
3.0 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, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.login-box {
background: white;
padding: 40px;
border-radius: 15px;
box-shadow: 0 15px 50px rgba(0,0,0,0.3);
width: 400px;
}
h2 { color: #333; margin-bottom: 30px; text-align: center; }
.form-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 8px; color: #555; font-weight: 500; }
input {
width: 100%;
padding: 12px;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-size: 14px;
transition: border-color 0.3s;
}
input:focus { border-color: #667eea; outline: none; }
.error { color: #e53935; font-size: 0.85em; margin-top: 5px; }
.error-field { border-color: #e53935 !important; }
button {
width: 100%;
padding: 14px;
background: #667eea;
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
cursor: pointer;
transition: background 0.3s;
}
button:hover { background: #764ba2; }
.tips {
background: #e8f5e9;
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
font-size: 0.9em;
color: #2e7d32;
}
a { color: #667eea; text-decoration: none; }
</style>
</head>
<body>
<div class="login-box">
<h2>🔐 用户登录</h2>
<div class="tips">
<strong>测试账号:</strong> admin / 123456
</div>
<!-- Struts2 表单标签 -->
<s:form action="login" method="post" namespace="/">
<div class="form-group">
<label>用户名</label>
<s:textfield name="username" placeholder="请输入用户名" cssClass="%{hasErrors('username') ? 'error-field' : ''}"/>
<s:fielderror fieldName="username"/>
</div>
<div class="form-group">
<label>密码</label>
<s:password name="password" placeholder="请输入密码" showPassword="true"/>
<s:fielderror fieldName="password"/>
</div>
<!-- 显示 Action 错误消息 -->
<s:actionerror/>
<button type="submit">登录</button>
</s:form>
<p style="text-align:center;margin-top:20px;">
<a href="index.jsp">← 返回首页</a>
</p>
</div>
</body>
</html>