创建一个精美的JSP登录界面涉及多个方面,包括前端设计、用户体验、安全性等。以下是一个基础的JSP登录界面的示例,以及一些优化建议。
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>登录</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.login-container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 300px;
}
.login-container h2 {
margin-bottom: 20px;
text-align: center;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
}
.form-group input[type="text"],
.form-group input[type="password"] {
width: calc(100% - 22px);
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
}
.form-group input[type="submit"] {
width: 100%;
padding: 10px;
background-color: #28a745;
border: none;
color: white;
border-radius: 4px;
cursor: pointer;
}
.form-group input[type="submit"]:hover {
background-color: #218838;
}
</style>
</head>
<body>
<div class="login-container">
<h2>用户登录</h2>
<form action="loginProcess.jsp" method="post">
<div class="form-group">
<label for="username">用户名</label>
<input type="text" id="username" name="username" required>
</div>
<div class="form-group">
<label for="password">密码</label>
<input type="password" id="password" name="password" required>
</div>
<div class="form-group">
<input type="submit" value="登录">
</div>
</form>
</div>
</body>
</html>action属性中的URL是否正确指向处理登录请求的JSP页面,并检查该页面是否有错误。通过以上步骤,你可以创建一个既美观又实用的JSP登录界面。希望这能帮助到你!
没有搜到相关的文章