代码应该按功能按职责进行不同层面的划分(放不同的包里)
用户层:交互页面
业务层:提供该软件系统的业务功能
持久层:提供基础数据的增删改查的操作
(最底层是数据库)
浏览器访问页面
http://localhost:8080/SchoolManager/login.jsp
不能用https
MySql数据库建立表
学生表
账号管理员表
定义Admin 和 Student 类
package com.iflytek.stumanager.po;
public class Admin {
private int id;
private String account;
private String password;
public Admin(int id, String account, String password) {
super();
this.id = id;
this.account = account;
this.password = password;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
package com.iflytek.stumanager.po;
public class Student {
private int id;
private String name;
private int age;
private String address;
public Student(int id, String name, int age, String address) {
super();
this.id = id;
this.name = name;
this.age = age;
this.address = address;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
建立JSPFile
先引入 Web jar包去掉报错
修改JSP的默认编码方式为UTF-8(可用汉字)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h2>用户登录</h2>
<hr />
<form action="" method="post">
账号:<input type="text" name="account" /><br />
密码:<input type="password" name="password" /><br />
<input type="submit" value="提交" />
</form>
</body>
</html>