1、登录:
2、注册:
一、编写User类,封装用户的信息
package entity;
public class User {
private String username;
private String password;
private String sex;
private String age;
public User() {
super();
// TODO Auto-generated constructor stub
}
public User(String username, String password, String sex, String age) {
super();
this.username = username;
this.password = password;
this.sex = sex;
this.age = age;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
}
二、编写登录、注册界面
login.jsp:
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>图书管理系统用户登录</title>
</head>
<center><h3>图书管理系统用户登录</h3></center>
<body style="text-align:center">
<form action="${pageContext.request.contextPath}/LoginServlet" method="post">
<table border="0" width="350px" cellpadding="0" cellspacing="0" align="center" style="background:#CFF;">
<tr>
<td height="50" align="center">用户名:
<input type="text" name="username" />${
errorMsg}</td>
</tr>
<tr>
<td height="50" align="center">密 码:
<input type="password" name="password" /></td>
</tr>
<tr>
<td heignt="50">
<input type="checkbox" name="autologin" value="${60*60*24*31}" />自动登录
</td>
</tr>
<tr>
<td height="50">
<input type="submit" value="登录" />