Servlet案例:用户注册登录
技术需求:html + Servlet + jdbc + tomcat
登录
创建数据库
创建登录界面login.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h2>登录</h2>
<form action="login" method="get">
<p>帐号:<input name="username" type="text"></p>
<p>密码:<input name="password" type="password"></p>
<p><input name="sub" type="submit" value="提交"></p>
</form>
</body>
</html>
创建用户实体User
public class User {
private int id;
private String username;//用户名
private String password;//密码
public User() {
}
public User(String username, String password) {
this.username = username;
this.password = password;
}
public int getId() {
return id;
}
public void setId