目录
一、项目展示
1.登录
2.业务块演示
3.教师信息显示(测试数据)
4.效果演示
二、项目简介
校园信息管理系统:主要是以老师和学生信息记录和统计功能。项目采用前后端分离架构思想,前端采用HTML+CSS+JS来实现页面效果展示,后端采用Servlet以及BeanUtils等技术。存储层使用高性能的MySQL,服务器使用Tomcat9.0.34,项目构建工具使用WEB-INF中lib来管理jar包。
三、 项目模块
四、项目代码展示
Dao层
TeacherDao(接口)
package com.school.dao;
import com.school.domain.Teacher;
import java.util.List;
public interface TeacherDao {
public Teacher findTeacherByName(String name);
public int addTeacher(Teacher teacher);
public boolean findTeacherByNameAndPassword(String name, String password);
public List<Teacher> findTeacherAll();
public int findCountTeacher();
public List<Teacher> findTeacherLimit(int pageNo,int pageSize);
public boolean deleteTeacherByID(Integer id);
public Teacher findTeacherByID(Integer id);
public int updateTeacher(Teacher teacher);
public List<Teacher> findTeacherByKey(int startIndex,int pageSize,String key, String value);
public int findTeacherCountByKey(String key, String value);
}
TeacherDaoImpl(实现类)
package com.school.dao.impl;
import com.school.dao.TeacherDao;
import com.school.domain.Teacher;
import com.school.service.impl.TeacherServiceImpl;
import com.school.utils.DBUtils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class TeacherDaoImpl implements TeacherDao{
//统计教师数
@Override
public int findTeacherCountByKey(String key, String value) {
Connection connection = null;
PreparedStatement ps = null;
ResultSet rs = null;
Teacher teacher = null;
int count = 0;
connection = DBUtils.getConnection();
String sql = "select count(*) from teacher";
try {
if ("姓名".equals(key)){
sql = sql + " where name like ?";
}
if ("性别".equals(key)){
sql = sql + " where gender like ?";
}
ps = connection.prepareStatement(sql);
ps.setString(1,"%"+value+"%");
rs = ps.executeQuery();
while(rs.next()){
count = rs.getInt(1);
}
} catch (SQLException e) {
e.printStackTrace();
}
DBUtils.closeDB(connection,ps,rs);
return count;
}
//查找教师
@Override
public List<Teacher> findTeacherByKey(int startIndex,int pageSize,String key, String value) {
Connection connection = null;
PreparedStatement ps = null;
ResultSet rs = null;
Teacher teacher = null;
connection = DBUtils.getConnection();
String sql = "select id,name,password,gender,email,remark,activatecode,state from teacher";
List<Teacher> teachers = new ArrayList<>();
try {
if ("姓名".equals(key)){
sql = sql + " where name like ? limit ?,?";
}
if ("性别".equals(key)){
sql = sql + " where gender like ? limit ?,?";
}
ps = connection.prepareStatement(sql);
ps.setString(1,"%"+value+"%");
ps.setInt(2,startIndex);
ps.setInt(3,pageSize);
rs = ps.executeQuery();
while(rs.next()){
teacher = new Teacher();
teacher.setId(rs.getInt(1));
teacher.setName(rs.getString(2));
teacher.setPassword(rs.getString(3));
teacher.setGender(rs.getString(4));
teacher.setEmail(rs.getString(5));
teacher.setRemark(rs.getString(6));
teacher.setActivatecode(rs.getString(7));
teacher.setState(rs.getString(8));
teachers.add(teacher);
}
} catch (SQLException e) {
e.printStackTrace();
}
DBUtils.closeDB(connection,ps,rs);
return teachers;
}
//修改教师信息
public int updateTeacher(Teacher teacher){
Connection connection = null;
String sql = null;
PreparedStatement ps = null;
int i = 0;
try {
connection = DBUtils.getConnection();
sql = "UPDATE teacher SET name=?,password=?,gender=?,email=?,remark=? where id = ?";
ps = connection.prepareStatement(sql);
ps.setString(1,teacher.getName());
ps.setString(2,teacher.getPassword());
ps.setString(3,teacher.getGender());
ps.setString(4,teacher.getEmail());
ps.setString(5,teacher.getRemark());
ps.setInt(6,teacher.getId());
i = ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
DBUtils.closeDB(connection,ps,null);
return i;
}
//通过ID查找教师
@Override
public Teacher findTeacherByID(Integer id) {
Connection connection = null;
PreparedStatement ps = null;
ResultSet rs = null;
Teacher teacher = null;
connection = DBUtils.getConnection();
String sql = "select id,name,password,gender,email,remark,activatecode,state from teacher WHERE id = ?";
try {
ps = connection.prepareStatement(sql);
ps.setInt(1,id);
rs = ps.executeQuery();
while(rs.next()){
teacher = new Teacher();
teacher.setId(rs.getInt(1));
teacher.setName(rs.getString(2));
teacher.setPassword(rs.getString(3));
teacher.setGender(rs.getString(4));
teacher.setEmail(rs.getString(5));
teacher.setRemark(rs.getString(6));
teacher.setActivatecode(rs.getString(7));
teacher.setState(rs.getString(8));
}
} catch (SQLException e) {
e.printStackTrace();
}
DBUtils.closeDB(connection,ps,rs);
return teacher;
}
//删除教师
@Override
public boolean deleteTeacherByID(Integer id) {
Connection connection = DBUtils.getConnection();
String sql = "DELETE FROM teacher WHERE id = ?";
PreparedStatement ps = null;
int i = 0;
boolean flag = false;
try {
ps = connection.prepareStatement(sql);
ps.setInt(1,id);
i = ps.executeUpdate();
if (i > 0){
flag = true;
}
} catch (SQLException e) {
e.printStackTrace();
}
DBUtils.closeDB(connection,ps,null);
return flag;
}
//分页
@Override
public List<Teacher> findTeacherLimit(int pageNo, int pageSize) {
Connection connection = DBUtils.getConnection();
String sql = "SELECT id,name,password,gender,email,activatecode,remark,state FROM teacher limit ?,?";
PreparedStatement ps = null;
ResultSet rs = null;
ArrayList<Teacher> teachers = new ArrayList<>();
try {
ps = connection.prepareStatement(sql);
ps.setInt(1,pageNo);
ps.setInt(2,pageSize);
rs = ps.executeQuery();
while (rs.next()){
Teacher teacher = new Teacher();
teacher.setId(rs.getInt(1));
teacher.setName(rs.getString(2));
teacher.setPassword(rs.getString(3));
teacher.setGender(rs.getString(4));
teacher.setEmail(rs.getString(5));
teacher.setRemark(rs.getString(6));
teacher.setActivatecode(rs.getString(7));
teacher.setState(rs.getString(8));
teachers.add(teacher);
}
} catch (SQLException e) {
e.printStackTrace();
}
DBUtils.closeDB(connection,ps,rs);
return teachers;
}
//统计总记录数
@Override
public int findCountTeacher() {
Connection connection = DBUtils.getConnection();
String sql = "select COUNT(*) from teacher";
PreparedStatement ps = null;
int i = 0;
try {
ps = connection.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
rs.next();
i = rs.getInt(1);
} catch (SQLException e) {
e.printStackTrace();
}
DBUtils.closeDB(connection,ps,null);
return i;
}
//查询所有老师
@Override
public List<Teacher> findTeacherAll() {
Connection connection = DBUtils.getConnection();
String sql = "select id,name,password,gender,email,remark,activatecode,state from teacher";
PreparedStatement ps = null;
ResultSet rs = null;
ArrayList<Teacher> teachers = new ArrayList<>();
try {
ps = connection.prepareStatement(sql);
rs = ps.executeQuery();
while (rs.next()){
Teacher teacher = new Teacher();
teacher.setId(rs.getInt(1));
teacher.setName(rs.getString(2));
teacher.setPassword(rs.getString(3));
teacher.setGender(rs.getString(4));
teacher.setEmail(rs.getString(5));
teacher.setRemark(rs.getString(6));
teacher.setActivatecode(rs.getString(7));
teacher.setState(rs.getString(8));
teachers.add(teacher);
}
} catch (SQLException e) {
e.printStackTrace();
}
DBUtils.closeDB(connection,ps,rs);
return teachers;
}
//通过名字和密码查询老师
@Override
public boolean findTeacherByNameAndPassword(String name, String password) {
Connection connection = DBUtils.getConnection();
String sql = "select id from teacher where name = ? AND password = ?";
PreparedStatement ps = null;
ResultSet rs = null;
boolean flag = false;
try {
ps = connection.prepareStatement(sql);
ps.setString(1,name);
ps.setString(2,password);
rs = ps.executeQuery();
while(rs.next()){
flag = true;
}
} catch (SQLException e) {
e.printStackTrace();
}
DBUtils.closeDB(connection,ps,rs);
return flag;
}
//通过名字查询老师
@Override
public Teacher findTeacherByName(String name) {
//连接数据库
Connection connection = null;
PreparedStatement ps = null;
ResultSet rs = null;
Teacher teacher = null;
connection = DBUtils.getConnection();
String sql = "select id,name,password,gender,email,remark,activatecode,state from teacher WHERE name = ?";
try {
ps = connection.prepareStatement(sql);
ps.setString(1,name);
rs = ps.executeQuery();
while(rs.next()){
teacher = new Teacher();
teacher.setId(rs.getInt(1));
teacher.setName(rs.getString(2));
teacher.setPassword(rs.getString(3));
teacher.setGender(rs.getString(4));
teacher.setEmail(rs.getString(5));
teacher.setRemark(rs.getString(6));
teacher.setActivatecode(rs.getString(7));
teacher.setState(rs.getString(8));
}
} catch (SQLException e) {
e.printStackTrace();
}
DBUtils.closeDB(connection,ps,rs);
return teacher;
}
//添加老师
@Override
public int addTeacher(Teacher teacher) {
Connection connection = DBUtils.getConnection();
String sql = "INSERT INTO teacher(name,password,gender,email,remark) VALUE (?,?,?,?,?)";
PreparedStatement ps = null;
int i = 0;
try {
ps = connection.prepareStatement(sql);
ps.setString(1,teacher.getName());
ps.setString(2,teacher.getPassword());
ps.setString(3,teacher.getGender());
ps.setString(4,teacher.getEmail());
ps.setString(5,teacher.getRemark());
i = ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
DBUtils.closeDB(connection,ps,null);
return i;
}
}
Service层
TeacherService(接口)
package com.school.service;
import com.school.domain.Page;
import com.school.domain.StateInfor;
import com.school.domain.Teacher;
import java.util.List;
public interface TeacherService {
public int register(Teacher teacher);
public boolean login(String name, String password);
public List<Teacher> showAllTeacher();
public Page findTeacherLimit(String splitUrl,int pageNum,int pageSize);
public boolean deleteTeacher(Integer id);
public StateInfor batchesDelete(String[] ids);
public Teacher showTeacherBack(Integer id);
public boolean modifyTeacher(Teacher teacher);
public Page queryTeacher(String url,int pageSize,int PageNum,String key, String value);
}
TeacherServiceImpl(实现类)
package com.school.service.impl;
import com.school.dao.TeacherDao;
import com.school.dao.impl.TeacherDaoImpl;
import com.school.domain.Page;
import com.school.domain.StateInfor;
import com.school.domain.Teacher;
import com.school.service.TeacherService;
import com.school.web.controller.TeacherController;
import java.util.List;
public class TeacherServiceImpl implements TeacherService {
//动态查询
@Override
public Page queryTeacher(String url,int pageSize,int pageNum,String key, String value) {
TeacherDao teacherDao = new TeacherDaoImpl();
int count = teacherDao.findTeacherCountByKey(key, value);
Page page = new Page(url,pageNum, count,pageSize);
List<Teacher> teachers = teacherDao.findTeacherByKey(page.getStartIndex(),page.getPageSize(),key, value);
page.setList(teachers);
return page;
}
//修改教师信息
@Override
public boolean modifyTeacher(Teacher teacher) {
int i = new TeacherDaoImpl().updateTeacher(teacher);
if (i > 0){
return true;
}else {
return false;
}
}
//数据回显
@Override
public Teacher showTeacherBack(Integer id) {
return new TeacherDaoImpl().findTeacherByID(id);
}
//批量删除
@Override
public StateInfor batchesDelete(String[] ids) {
TeacherDao teacherDao = new TeacherDaoImpl();
StateInfor stateInfor = new StateInfor();
for (String id : ids) {
Teacher teacher = teacherDao.findTeacherByID(Integer.parseInt(id));
if (teacher == null){
stateInfor.setStateId(0);
stateInfor.setTeacherId(id);
return stateInfor;
}
}
for (String id : ids) {
boolean b = teacherDao.deleteTeacherByID(Integer.parseInt(id));
if (b == false){
stateInfor.setStateId(0);
stateInfor.setTeacherId(id);
return stateInfor;
}
}
stateInfor.setStateId(2);
return stateInfor;
}
//删除用户
@Override
public boolean deleteTeacher(Integer id) {
TeacherDao teacherDao = new TeacherDaoImpl();
boolean b = teacherDao.deleteTeacherByID(id);
return b;
}
//分页查询
@Override
public Page findTeacherLimit(String splitUrl,int pageNum,int pageSize) {
TeacherDao teacherDao = new TeacherDaoImpl();
int totalNum = teacherDao.findCountTeacher();
Page page = new Page(splitUrl,pageNum,totalNum,pageSize);
List<Teacher> teachers = teacherDao.findTeacherLimit(page.getStartIndex(), page.getPageSize());
page.setList(teachers);
return page;
}
//显示所有用户
@Override
public List<Teacher> showAllTeacher() {
List<Teacher> teachers = new TeacherDaoImpl().findTeacherAll();
return teachers;
}
//登录
@Override
public boolean login(String name, String password) {
TeacherDao teacherDao = new TeacherDaoImpl();
boolean flag = teacherDao.findTeacherByNameAndPassword(name, password);
return flag;
}
//注册
@Override
public int register(Teacher teacher) {
//判断用户是否存在
TeacherDao teacherDao = new TeacherDaoImpl();
int flag = 0;//flag:0代表注册失败,1代表注册成功,2代表用户存在
Teacher teacherByName = teacherDao.findTeacherByName(teacher.getName());
if (teacherByName != null){
flag = 2;//用户存在
}else {
int i = teacherDao.addTeacher(teacher);
if (i > 0){
flag = 1;
}else{
flag = 0;
}
}
return flag;
}
}
Controller层
TeacherController
package com.school.web.controller;
import com.school.dao.impl.TeacherDaoImpl;
import com.school.domain.Page;
import com.school.domain.StateInfor;
import com.school.domain.Teacher;
import com.school.service.TeacherService;
import com.school.service.impl.TeacherServiceImpl;
import com.school.web.validate.ValidateDemo;
import org.apache.commons.beanutils.BeanUtils;
import org.omg.PortableInterceptor.INACTIVE;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
@WebServlet("/TeacherController")
public class TeacherController extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String action = req.getParameter("action");
//动态查询
if ("queryTeacher".equals(action)){
String key = req.getParameter("key");
String value = req.getParameter("value");
int pageNum = Integer.parseInt(req.getParameter("pageNum"));
if (pageNum == 0){
pageNum = 1;
}
int pageSize = Integer.parseInt(req.getParameter("pageSize"));
if (pageSize == 0){
pageSize = 10;
}
if (key != null && value != null && !("".equals(key.trim())) && !("".equals(value.trim()))){
TeacherService teacherService = new TeacherServiceImpl();
Page page = teacherService.queryTeacher("TeacherController", pageSize, pageNum, key, value);
req.setAttribute("page",page );
req.setAttribute("action","queryTeacher" );
req.setAttribute("key",key );
req.setAttribute("value",value);
req.getRequestDispatcher("/pages/teacher.jsp").forward(req,resp);
}else {
resp.getWriter().print("查询失败!");
}
}
//修改
if ("modifyTeacher".equals(action)){
Teacher teacher = new Teacher();
try {
BeanUtils.populate(teacher,req.getParameterMap());
boolean flag = new TeacherServiceImpl().modifyTeacher(teacher);
int pageNum = Integer.parseInt(req.getParameter("pageNum"));
if (flag){
req.getRequestDispatcher("TeacherController?action=splitPage").forward(req,resp );
}else {
resp.getWriter().print("修改失败");
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
//数据回显
if ("showTeacherBack".equals(action)){
String id = req.getParameter("id");
String pageNum = req.getParameter("pageNum");
req.setAttribute("pageNum",pageNum );
TeacherService teacherService = new TeacherServiceImpl();
Teacher teacher = teacherService.showTeacherBack(Integer.parseInt(id));
req.setAttribute("teacher", teacher);
req.getRequestDispatcher("/pages/showteacherback.jsp").forward(req,resp );
}
//批量删除
if ("batchesDelete".equals(action)){
String[] ids = req.getParameterValues("ids");
TeacherService teacherService = new TeacherServiceImpl();
StateInfor stateInfor = teacherService.batchesDelete(ids);
if (0 == stateInfor.getStateId()){
resp.getWriter().print(stateInfor.getStateId()+"号不存在");
}
if (1 == stateInfor.getStateId()){
resp.getWriter().print("删除失败");
}
if (2 == stateInfor.getStateId()){
req.getRequestDispatcher("TeacherController?action=splitPage").forward(req,resp );
}
}
//单个删除
if ("deleteTeacher".equals(action)){
String id = req.getParameter("id");
String pageNum = req.getParameter("pageNum");
TeacherService teacherService = new TeacherServiceImpl();
boolean flag = teacherService.deleteTeacher(Integer.parseInt(id));
if (flag){
Page page = teacherService.findTeacherLimit("TeacherController", Integer.parseInt(pageNum), 10);
req.setAttribute("page",page);
req.getRequestDispatcher("/pages/teacher.jsp").forward(req,resp);
}else {
resp.getWriter().print("删除失败");
}
}
//设置每页显示个数
if ("setPageSize".equals(action)){
int pageSize = Integer.parseInt(req.getParameter("pageSize"));
req.getSession().setAttribute("pageSize",pageSize );
TeacherService teacherService = new TeacherServiceImpl();
Page page = teacherService.findTeacherLimit("TeacherController",1,pageSize);
req.setAttribute("page",page);
req.setAttribute("action",action );
req.getRequestDispatcher("/pages/teacher.jsp").forward(req,resp);
}
//分页
if ("splitPage".equals(action)){
String splitUrl = req.getParameter("splitUrl");
int pageNum = Integer.parseInt(req.getParameter("pageNum"));
Object pageSize = req.getSession().getAttribute( "pageSize");
if (pageSize == null){
TeacherService teacherService = new TeacherServiceImpl();
Page page = teacherService.findTeacherLimit("TeacherController",pageNum,10);
req.setAttribute("page",page);
req.setAttribute("action","splitPage" );
req.getRequestDispatcher("/pages/teacher.jsp").forward(req,resp);
}else {
TeacherServiceImpl teacherService = new TeacherServiceImpl();
Page page = teacherService.findTeacherLimit("TeacherController",pageNum,(int)pageSize);
req.setAttribute("page",page);
req.setAttribute("action","splitPage" );
req.getRequestDispatcher("/pages/teacher.jsp").forward(req,resp);
}
}
//查询所有老师
if ("showAllTeacher".equals(action)){
TeacherService teacherService = new TeacherServiceImpl();
List<Teacher> teachers = teacherService.showAllTeacher();
if (teachers.isEmpty()){
req.setAttribute("infor","未查到用户相关信息");
req.getRequestDispatcher("/pages/teacher.jsp").forward(req,resp);
}else {
req.setAttribute("teachers",teachers);
req.getRequestDispatcher("/pages/teacher.jsp").forward(req,resp);
}
}
//注销
if ("logout".equals(action)){
req.getSession().removeAttribute("name");
req.getRequestDispatcher("logoutsuccess.jsp").forward(req,resp);
}
//登录
if ("login".equals(action)) {
String checkcode = req.getParameter("checkcode");
String infor = (String) req.getSession().getAttribute("infor");
if (checkcode != null && checkcode.equalsIgnoreCase(infor)){
Teacher teacher = new Teacher();
try {
BeanUtils.populate(teacher,req.getParameterMap());
Map<String, String> error = ValidateDemo.validateLogin(teacher);
if (error.isEmpty()){
String name = req.getParameter("name");
String password = req.getParameter("password");
TeacherService userService = new TeacherServiceImpl();
boolean flag = userService.login(name, password);
if (flag){
//判断是否需要用户名和密码
String[] autoLogins = req.getParameterValues("remember");
if (autoLogins != null && autoLogins.length > 0){
//记录用户名和密码
Cookie nameCookie = new Cookie("name", name);
Cookie psdCookie = new Cookie("password",password);
nameCookie.setMaxAge(2592000);
psdCookie.setMaxAge(2592000);
nameCookie.setPath("/schoolpro02");
psdCookie.setPath("/schoolpro02");
resp.addCookie(nameCookie);
resp.addCookie(psdCookie);
//设置一个登录成功的标志
req.getSession().setAttribute("name",name);
req.getRequestDispatcher("/pages/index.jsp").forward(req,resp);
}else {
req.getSession().setAttribute("name",name);
req.getRequestDispatcher("/pages/index.jsp").forward(req,resp);
}
}else {
req.setAttribute("fail","登录失败!");
req.getRequestDispatcher("/login.jsp").forward(req,resp);
}
}else {
req.setAttribute("error",error);
req.getRequestDispatcher("/login.jsp").forward(req,resp);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}else {
req.setAttribute("codefail","验证码错误,请重新输入");
req.getRequestDispatcher("/login.jsp").forward(req,resp);
}
Teacher teacher = new Teacher();
}
//注册
if ("register".equals(action)){
System.out.println("111");
//接收数据以及封装
Teacher teacher = new Teacher();
try {
BeanUtils.populate(teacher,req.getParameterMap());
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
//验证
Map<String, String> error = ValidateDemo.validateTeacher(teacher);
if (error.isEmpty()){
//调用service方法
TeacherService teacherService = new TeacherServiceImpl();
int flag = teacherService.register(teacher);
if (flag==0){
req.getRequestDispatcher("/pages/registerfail.jsp").forward(req,resp);
}
if (flag == 1){
req.getRequestDispatcher("/pages/registersuccess.jsp").forward(req,resp);
}
if (flag == 2){
req.setAttribute("registerInfor","该用户已存在!");
req.getRequestDispatcher("/register_teacher.jsp").forward(req,resp);
}
}else {
req.setAttribute("error",error);
req.getRequestDispatcher("/register_teacher.jsp").forward(req,resp);
}
}
}
}
Domain层
Page
package com.school.domain;
import java.io.Serializable;
import java.util.List;
/**
* 封装分页所需相关信息
*/
public class Page implements Serializable{
private int pageNum; // 当前页码
private int totalNum; // 数据库查询
private int pageSize = 10; // 自定义
private int totalPageNum; //总页数
private int startIndex;
private int startPage; //首页
private int endPage; //尾页
private List<?> list = null;
private String url;
public Page(String url,int pageNum, int totalNum, int pageSize) {
this.pageNum = pageNum;
this.totalNum = totalNum;
this.pageSize = pageSize;
this.url = url;
//总页数
if (totalNum % pageSize == 0){
totalPageNum = totalNum / pageSize;
}else {
totalPageNum = totalNum / pageSize + 1;
}
//每页的起始数据
startIndex = (pageNum - 1)*pageSize;
//控制切换页面的坐标
if (totalPageNum < 5){
startPage = 1;
endPage = totalPageNum;
}else {
if (pageNum < 3){
startPage = 1;
endPage = 5;
}else{
if (pageNum > (totalPageNum - 3)){
startPage = totalPageNum - 4;
endPage = totalPageNum;
}else {
startPage = pageNum - 2;
endPage = pageNum + 2;
}
}
}
}
public int getPageNum() {
return pageNum;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public int getTotalNum() {
return totalNum;
}
public void setTotalNum(int totalNum) {
this.totalNum = totalNum;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getTotalPageNum() {
return totalPageNum;
}
public void setTotalPageNum(int totalPageNum) {
this.totalPageNum = totalPageNum;
}
public int getStartIndex() {
return startIndex;
}
public void setStartIndex(int startIndex) {
this.startIndex = startIndex;
}
public int getStartPage() {
return startPage;
}
public void setStartPage(int startPage) {
this.startPage = startPage;
}
public int getEndPage() {
return endPage;
}
public void setEndPage(int endPage) {
this.endPage = endPage;
}
public List<?> getList() {
return list;
}
public void setList(List<?> list) {
this.list = list;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public String toString() {
return "Page{" +
"pageNum=" + pageNum +
", totalNum=" + totalNum +
", pageSize=" + pageSize +
", totalPageNum=" + totalPageNum +
", startIndex=" + startIndex +
", startPage=" + startPage +
", endPage=" + endPage +
", list=" + list +
", url='" + url + '\'' +
'}';
}
}
StateInfor
package com.school.domain;
import java.io.Serializable;
/**
* 封装状态信息
*/
public class StateInfor implements Serializable{
private int stateId;
private String teacherId;
public int getStateId() {
return stateId;
}
public void setStateId(int stateId) {
this.stateId = stateId;
}
public String getTeacherId() {
return teacherId;
}
public void setTeacherId(String teacherId) {
this.teacherId = teacherId;
}
}
Teacher
package com.school.domain;
import java.io.Serializable;
/**
* 封装教师信息等相关数据
*/
public class Teacher implements Serializable{
private Integer id;
private String name;
private String password;
private String gender;
private String email;
private String remark;
private String activatecode;
private String state;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getActivatecode() {
return activatecode;
}
public void setActivatecode(String activatecode) {
this.activatecode = activatecode;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
@Override
public String toString() {
return "Teacher{" +
"id=" + id +
", name='" + name + '\'' +
", password='" + password + '\'' +
", gender='" + gender + '\'' +
", email='" + email + '\'' +
", remark='" + remark + '\'' +
", activatecode='" + activatecode + '\'' +
", state='" + state + '\'' +
'}';
}
}