html+css+jsp登录注册页面
时间: 2024-06-16 21:04:20 浏览: 21
HTML、CSS和JSP是常用于构建网页和实现用户交互的前端技术。下面是一个简单的HTML+CSS+JSP登录注册页面的示例:
HTML部分:
```html
<!DOCTYPE html>
<html>
<head>
<title>登录注册页面</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
<h1>登录</h1>
<form action="login.jsp" method="POST">
<label for="username">用户名:</label>
<input type="text" id="username" name="username" required><br>
<label for="password">密码:</label>
<input type="password" id="password" name="password" required><br>
<input type="submit" value="登录">
</form>
<h1>注册</h1>
<form action="register.jsp" method="POST">
<label for="newUsername">用户名:</label>
<input type="text" id="newUsername" name="newUsername" required><br>
<label for="newPassword">密码:</label>
<input type="password" id="newPassword" name="newPassword" required><br>
<input type="submit" value="注册">
</form>
</div>
</body>
</html>
```
CSS部分(style.css):
```css
.container {
width: 300px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ccc;
}
h1 {
text-align: center;
}
label {
display: block;
margin-bottom: 10px;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 5px;
margin-bottom: 10px;
}
input[type="submit"] {
width: 100%;
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
```
JSP部分(login.jsp和register.jsp):
```jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>登录注册页面</title>
</head>
<body>
<%--%>
<% if (request.getParameter("username") != null && request.getParameter("password") != null) { %>
<% String username = request.getParameter("username"); %>
<% String password = request.getParameter("password"); %>
<%-- 在这里进行登录验证的逻辑处理 --%>
<%-- 如果验证通过,可以进行页面跳转或其他操作 --%>
<h2>登录成功!</h2>
<% } %>
<%-- 注册处理 --%>
<% if (request.getParameter("newUsername") != null && request.getParameter("newPassword") != null) { %>
<% String newUsername = request.getParameter("newUsername"); %>
<% String newPassword = request.getParameter("newPassword"); %>
<%-- 在这里进行注册逻辑处理 --%>
<%-- 如果注册成功,可以进行页面跳转或其他操作 --%>
<h2>注册成功!</h2>
<% } %>
</body>
</html>
```
以上是一个简单的HTML+CSS+JSP登录注册页面的示例,你可以根据自己的需求进行修改和扩展。