Compare commits

..

No commits in common. 'master' and 'wyy_branch' have entirely different histories.

@ -1,11 +1,34 @@
package dao;
import domain.Admin;
import domain.Admin; // 引入 Admin 类,表示管理员数据
/**
* AdminDao 访
*/
public interface AdminDao {
/**
* ID
*
* @param id ID
* @param password
* @return null
*/
Admin findAdminidAndPassword(String id, String password);
/**
*
*
* @param adminid ID
* @param newpassword
*/
void updatePassword(String adminid, String newpassword);
/**
* ID
*
* @param a_id ID
* @return null
*/
Admin findAdminById(String a_id);
}

@ -1,15 +1,39 @@
package dao;
import domain.CDC;
import domain.CDC; // 引入 CDC 类,表示学院、部门和班级的数据
import java.util.List;
import java.util.List; // 引入 List 类,用于存储返回的查询结果
/**
* CDCDao 访
*/
public interface CDCDao {
/**
*
*
* @return
*/
List<CDC> findAllCollege();
/**
*
*
* @return
*/
List<CDC> findAllDepartment();
/**
*
*
* @return
*/
List<CDC> findAllClass();
/**
*
*
* @return
*/
List<CDC> findAll();
}

@ -1,11 +1,25 @@
package dao;
import domain.Complaint;
import domain.Complaint; // 引入 Complaint 类,表示投诉数据
import java.util.List;
import java.util.List; // 引入 List 类,用于存储返回的投诉列表
/**
* ComplaintDao 访
*/
public interface ComplaintDao {
/**
*
*
* @return
*/
List<Complaint> findAllComplaint();
/**
*
*
* @param complaint
*/
void addComplaint(Complaint complaint);
}

@ -1,11 +1,31 @@
package dao;
import domain.Course;
import domain.Course; // 引入 Course 类,表示课程数据
/**
* CourseDao 访
*/
public interface CourseDao {
/**
*
*
* @param course
*/
void addOptionalCourse(Course course);
/**
* ID
*
* @param cid ID
* @return Course null
*/
Course findSelectCourseByCourseId(String cid);
/**
* ID
*
* @param cid ID
*/
void deleteServiceById(String cid);
}

@ -1,16 +1,39 @@
package dao;
import domain.Notify;
import domain.Notify; // 引入 Notify 类,表示通知数据
import java.util.List;
import java.util.List; // 引入 List 类,表示通知列表
/**
* NotifyDao 访
*/
public interface NotifyDao {
/**
*
*
* @param notify
*/
void add(Notify notify);
/**
* 3
*
* @return 3 List<Notify>
*/
List<Notify> findNotify();
/**
* ID
*
* @return List<Notify>
*/
List<Notify> findAllNotify();
/**
* ID
*
* @param notifyid ID
*/
void deleteNotifyById(String notifyid);
}

@ -1,11 +1,31 @@
package dao;
import domain.Photo;
import domain.Photo; // 引入 Photo 类,表示照片数据
/**
* PhotoDao 访
*/
public interface PhotoDao {
/**
*
*
* @param photo
*/
void addPhoto(Photo photo);
/**
* ID
*
* @param id ID
* @return Photo null
*/
Photo findPhotoByPhotoId(String id);
/**
*
*
* @param photo
*/
void updatePhoto(Photo photo);
}

@ -1,13 +1,37 @@
package dao;
import domain.SelectCourse;
import domain.SelectCourse; // 引入 SelectCourse 类,表示学生选课数据
import java.util.List;
import java.util.List; // 引入 List 类,用于返回多个选课记录
/**
* SelectCourseDao 访
*/
public interface SelectCourseDao {
/**
* ID
*
* @param cid ID
* @return ID ID
*/
List<SelectCourse> findStudentSelectedCourseByCourseId(String cid);
/**
* ID ID
*
* @param cid ID
* @param sid ID
* @return
*/
SelectCourse findScoreByCourseIdAndStudentId(String cid, String sid);
/**
*
*
* @param cid ID
* @param sid ID
* @param sScore
*/
void upDateScoreByCidAndSid(String cid, String sid, String sScore);
}

@ -1,41 +1,122 @@
package dao;
import domain.Course;
import domain.SelectCourse;
import domain.Student;
import domain.Course; // 引入 Course 类,表示课程信息
import domain.SelectCourse; // 引入 SelectCourse 类,表示学生的选课信息
import domain.Student; // 引入 Student 类,表示学生信息
import java.util.List;
import java.util.Map;
import java.util.List; // 引入 List 类,用于返回多个学生或选课记录
import java.util.Map; // 引入 Map 类,用于接收条件查询参数
/**
* DAO
* DAO
*/
public interface StudentDao {
/**
*
*
* @param start
* @param rows
* @param condition Map
* @return
*/
List<Student> findByPage(int start, int rows, Map<String, String[]> condition);
/**
*
*
* @return
*/
List<Student> findAll();
/**
* ID
*
* @param id
* @param password
* @return null
*/
Student findStudentidAndPassword(String id, String password);
/**
* ID
*
* @param s_id
* @return
*/
Student findStudentById(String s_id);
/**
*
*
* @param student
*/
void addStudent(Student student);
/**
*
*
* @param student
*/
void updateInfo(Student student);
/**
*
*
* @param studentid
* @param newpassword
*/
void updatePassword(String studentid, String newpassword);
/**
*
*
* @param studentid
* @return
*/
List<SelectCourse> findAllSelectCourse(String studentid);
/**
*
*
* @return
*/
List<Course> findAllOptionalCourse();
/**
*
*
* @param studentid
* @param courseid ID
*/
void addSelectCourse(String studentid, String courseid);
/**
* ID
*
* @param studentid
*/
void deleteStudentById(String studentid);
/**
*
*
* @param condition Map
* @return
*/
int findTotalCount(Map<String, String[]> condition);
/**
*
*
* @param updateStudent
*/
void addStudentAllInfo(Student updateStudent);
/**
*
*
* @return
*/
List<SelectCourse> findSelectCourseAllStudent();
}

@ -1,33 +1,95 @@
package dao;
import domain.Course;
import domain.Teacher;
import domain.Course; // 引入 Course 类,表示课程信息
import domain.Teacher; // 引入 Teacher 类,表示教师信息
import java.util.List;
import java.util.List; // 引入 List 类,用于返回多个教师或课程信息
/**
* DAO
* DAO
*/
public interface TeacherDao {
/**
* ID
*
* @param id
* @param password
* @return null
*/
Teacher findTeacheridAndPassword(String id, String password);
/**
*
*
* @return
*/
List<Teacher> findAll();
/**
* ID
*
* @param t_id
* @return
*/
List<Course> findMySelfOptionalCourse(String t_id);
/**
* ID
*
* @param cid ID
* @return
*/
Course findOptionalCourseByCourseId(String cid);
/**
*
*
* @param updateCourse
*/
void updateCourseInfo(Course updateCourse);
/**
*
*
* @param cid ID
*/
void deleteCourseById(String cid);
/**
*
*
* @param teacherid
* @param newpassword
*/
void updatePassword(String teacherid, String newpassword);
/**
* ID
*
* @param t_id
* @return
*/
Teacher findTeacherById(String t_id);
/**
*
*
* @param updateTeacher
*/
void addTeacherAllInfo(Teacher updateTeacher);
/**
* ID
*
* @param teacherid
*/
void deleteTeacherById(String teacherid);
/**
*
*
* @param updateTeacher
*/
void updateInfo(Teacher updateTeacher);
}

@ -1,46 +1,79 @@
package dao.impl;
import dao.AdminDao;
import domain.Admin;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import utils.JDBCUtils;
import dao.AdminDao; // 引入 AdminDao 接口,定义管理员相关的数据访问方法
import domain.Admin; // 引入 Admin 实体类,表示管理员数据
import org.springframework.dao.DataAccessException; // 引入数据库访问异常类
import org.springframework.jdbc.core.BeanPropertyRowMapper; // 用于将查询结果映射为 Java 对象
import org.springframework.jdbc.core.JdbcTemplate; // JDBC 操作模板,用于简化数据库操作
import utils.JDBCUtils; // 自定义工具类,用于获取数据库数据源
/**
* AdminDaoImpl
*/
public class AdminDaoImpl implements AdminDao {
// 使用 JdbcTemplate 对数据库进行操作JDBCUtils 提供数据源
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
/**
* ID
*
* @param id ID
* @param password
* @return null
*/
@Override
public Admin findAdminidAndPassword(String id, String password) {
try {
// SQL 查询语句:根据管理员 ID 和密码查询管理员
String sql = "select * from admin where a_id = ? and a_password = ?";
Admin admin = template.queryForObject(sql,new BeanPropertyRowMapper<Admin>(Admin.class),id,password);
return admin;
// 执行查询,并将结果映射为 Admin 对象
Admin admin = template.queryForObject(sql, new BeanPropertyRowMapper<>(Admin.class), id, password);
return admin; // 返回找到的管理员
} catch (DataAccessException e) {
// 捕获数据库访问异常并打印堆栈信息
e.printStackTrace();
return null;
return null; // 查询失败时返回 null
}
}
/**
*
*
* @param adminid ID
* @param newpassword
*/
@Override
public void updatePassword(String adminid, String newpassword) {
try {
// SQL 更新语句:根据管理员 ID 更新密码
String sql = "update admin set a_password=? where a_id=?";
template.update(sql,newpassword,adminid);
// 执行更新操作
template.update(sql, newpassword, adminid);
} catch (Exception e) {
// 捕获异常并打印堆栈信息
e.printStackTrace();
}
}
/**
* ID
*
* @param id ID
* @return null
*/
@Override
public Admin findAdminById(String id) {
try {
// SQL 查询语句:根据管理员 ID 查询管理员
String sql = "select * from admin where a_id = ?";
Admin admin = template.queryForObject(sql,new BeanPropertyRowMapper<Admin>(Admin.class),id);
return admin;
// 执行查询,并将结果映射为 Admin 对象
Admin admin = template.queryForObject(sql, new BeanPropertyRowMapper<>(Admin.class), id);
return admin; // 返回找到的管理员
} catch (DataAccessException e) {
// 捕获数据库访问异常并打印堆栈信息
e.printStackTrace();
return null;
return null; // 查询失败时返回 null
}
}
}

@ -1,62 +1,92 @@
package dao.impl;
import dao.CDCDao;
import domain.CDC;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import utils.JDBCUtils;
// 引入相关类和接口
import dao.CDCDao; // 数据访问对象DAO接口
import domain.CDC; // 表示 CDC 表数据结构的实体类
import org.springframework.dao.DataAccessException; // 数据访问异常类
import org.springframework.jdbc.core.BeanPropertyRowMapper; // 用于将结果集映射为实体类
import org.springframework.jdbc.core.JdbcTemplate; // Spring 的 JDBC 模板类
import utils.JDBCUtils; // 自定义的工具类,用于获取数据源
import java.util.List;
import java.util.List; // Java 的 List 接口
/**
* CDCDaoImpl CDCDao CDC
*/
public class CDCDaoImpl implements CDCDao {
// 使用 JdbcTemplate 进行数据库操作,通过 JDBCUtils 获取数据源
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
/**
*
* @return CDC null
*/
@Override
public List<CDC> findAllCollege() {
try {
// SQL 语句:获取去重的学院名称
String sql = "select distinct college from college_department_class";
// 使用 JdbcTemplate 执行查询,并将结果映射为 CDC 对象
List<CDC> cdcs = template.query(sql, new BeanPropertyRowMapper<CDC>(CDC.class));
return cdcs;
return cdcs; // 返回查询结果
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 打印异常堆栈信息
return null; // 查询失败时返回 null
}
}
/**
*
* @return CDC null
*/
@Override
public List<CDC> findAllDepartment() {
try {
// SQL 语句:获取去重的系名称
String sql = "select distinct department from college_department_class";
// 使用 JdbcTemplate 执行查询,并将结果映射为 CDC 对象
List<CDC> cdcs = template.query(sql, new BeanPropertyRowMapper<CDC>(CDC.class));
return cdcs;
return cdcs; // 返回查询结果
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 打印异常堆栈信息
return null; // 查询失败时返回 null
}
}
/**
*
* @return CDC null
*/
@Override
public List<CDC> findAllClass() {
try {
// SQL 语句:获取去重的班级名称
String sql = "select distinct cclass from college_department_class";
// 使用 JdbcTemplate 执行查询,并将结果映射为 CDC 对象
List<CDC> cdcs = template.query(sql, new BeanPropertyRowMapper<CDC>(CDC.class));
return cdcs;
return cdcs; // 返回查询结果
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 打印异常堆栈信息
return null; // 查询失败时返回 null
}
}
/**
*
* @return CDC null
*/
@Override
public List<CDC> findAll() {
try {
// SQL 语句:获取表中所有数据
String sql = "select * from college_department_class";
// 使用 JdbcTemplate 执行查询,并将结果映射为 CDC 对象
List<CDC> cdcs = template.query(sql, new BeanPropertyRowMapper<CDC>(CDC.class));
return cdcs;
return cdcs; // 返回查询结果
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 打印异常堆栈信息
return null; // 查询失败时返回 null
}
}
}

@ -1,36 +1,54 @@
package dao.impl;
import dao.ComplaintDao;
import domain.Complaint;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import utils.JDBCUtils;
// 引入相关类和接口
import dao.ComplaintDao; // 数据访问对象DAO接口
import domain.Complaint; // 表示 Complaint 表数据结构的实体类
import org.springframework.dao.DataAccessException; // 数据访问异常类
import org.springframework.jdbc.core.BeanPropertyRowMapper; // 用于将结果集映射为实体类
import org.springframework.jdbc.core.JdbcTemplate; // Spring 的 JDBC 模板类
import utils.JDBCUtils; // 自定义工具类,用于获取数据源
import java.util.List;
import java.util.List; // Java 的 List 接口
/**
* ComplaintDaoImpl ComplaintDao Complaint
*/
public class ComplaintDaoImpl implements ComplaintDao {
// 使用 JdbcTemplate 进行数据库操作,通过 JDBCUtils 获取数据源
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
/**
* ID
* @return null
*/
@Override
public List<Complaint> findAllComplaint() {
try {
// SQL 语句:查询所有投诉记录并按 ID 倒序排列
String sql = "select * from complaint order by id DESC";
// 使用 JdbcTemplate 执行查询,并将结果映射为 Complaint 对象列表
List<Complaint> complaints = template.query(sql, new BeanPropertyRowMapper<Complaint>(Complaint.class));
return complaints;
return complaints; // 返回查询结果
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 打印异常堆栈信息
return null; // 查询失败时返回 null
}
}
/**
*
* @param complaint
*/
@Override
public void addComplaint(Complaint complaint) {
try {
// SQL 语句:向 complaint 表插入记录
String sql = "insert into complaint(cdate,content) values(?,?)";
template.update(sql,complaint.getCdate(),complaint.getContent());
// 使用 JdbcTemplate 执行更新操作
template.update(sql, complaint.getCdate(), complaint.getContent());
} catch (DataAccessException e) {
e.printStackTrace();
e.printStackTrace(); // 打印异常堆栈信息
}
}
}

@ -1,44 +1,69 @@
package dao.impl;
import dao.CourseDao;
import domain.Course;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import utils.JDBCUtils;
// 引入相关类和接口
import dao.CourseDao; // 数据访问对象DAO接口
import domain.Course; // 表示 Course 表数据结构的实体类
import org.springframework.dao.DataAccessException; // 数据访问异常类
import org.springframework.jdbc.core.BeanPropertyRowMapper; // 用于将结果集映射为实体类
import org.springframework.jdbc.core.JdbcTemplate; // Spring 的 JDBC 模板类
import utils.JDBCUtils; // 自定义工具类,用于获取数据源
/**
* CourseDaoImpl CourseDao Course
*/
public class CourseDaoImpl implements CourseDao {
// 使用 JdbcTemplate 进行数据库操作,通过 JDBCUtils 获取数据源
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
/**
*
* @param c Course
*/
@Override
public void addOptionalCourse(Course c) {
try {
// SQL 语句:向 course 表插入课程记录
String sql = "insert into course values(?,?,?,?)";
template.update(sql,c.getC_id(),c.getC_name(),c.getT_id(),c.getC_info());
// 使用 JdbcTemplate 执行插入操作
template.update(sql, c.getC_id(), c.getC_name(), c.getT_id(), c.getC_info());
} catch (DataAccessException e) {
e.printStackTrace();
e.printStackTrace(); // 打印异常堆栈信息
}
}
/**
* ID
* @param cid ID
* @return null
*/
@Override
public Course findSelectCourseByCourseId(String cid) {
try {
// SQL 语句:根据课程 ID 查找对应课程信息
String sql = "select * from course where c_id = ?";
Course course = template.queryForObject(sql,new BeanPropertyRowMapper<Course>(Course.class),cid);
return course;
// 使用 JdbcTemplate 执行查询,并将结果映射为 Course 对象
Course course = template.queryForObject(sql, new BeanPropertyRowMapper<Course>(Course.class), cid);
return course; // 返回查询结果
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 打印异常堆栈信息
return null; // 查询失败时返回 null
}
}
/**
* ID
* @param cid ID
*/
@Override
public void deleteServiceById(String cid) {
try {
// SQL 语句:根据课程 ID 删除对应课程记录
String sql = "delete from course where c_id=?";
template.update(sql,cid);
// 使用 JdbcTemplate 执行删除操作
template.update(sql, cid);
} catch (DataAccessException e) {
e.printStackTrace();
e.printStackTrace(); // 打印异常堆栈信息
}
}
}

@ -1,58 +1,88 @@
package dao.impl;
import dao.NotifyDao;
import domain.Notify;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import utils.JDBCUtils;
// 引入相关类和接口
import dao.NotifyDao; // 数据访问对象DAO接口
import domain.Notify; // 表示 Notify 表数据结构的实体类
import org.springframework.dao.DataAccessException; // 数据访问异常类
import org.springframework.jdbc.core.BeanPropertyRowMapper; // 用于将结果集映射为实体类
import org.springframework.jdbc.core.JdbcTemplate; // Spring 的 JDBC 模板类
import utils.JDBCUtils; // 自定义工具类,用于获取数据源
import java.util.List;
import java.util.List; // Java 的 List 接口
/**
* NotifyDaoImpl NotifyDao Notify
*/
public class NotifyDaoImpl implements NotifyDao {
// 使用 JdbcTemplate 进行数据库操作,通过 JDBCUtils 获取数据源
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
/**
*
* @param notify Notify
*/
@Override
public void add(Notify notify) {
try {
String sql = "insert into notify(notifyDate,notifyInfo) values(?,?)";
template.update(sql,notify.getNotifyDate(),notify.getNotifyInfo());
// SQL 语句:向 notify 表插入通知记录
String sql = "insert into notify(notifyDate, notifyInfo) values(?, ?)";
// 使用 JdbcTemplate 执行插入操作
template.update(sql, notify.getNotifyDate(), notify.getNotifyInfo());
} catch (DataAccessException e) {
e.printStackTrace();
e.printStackTrace(); // 打印异常堆栈信息
}
}
/**
* ID
* @return List null
*/
@Override
public List<Notify> findAllNotify() {
try {
// SQL 语句:查询所有通知记录并按 ID 倒序排列
String sql = "select * from notify order by id DESC";
// 使用 JdbcTemplate 执行查询,并将结果映射为 Notify 对象列表
List<Notify> notifys = template.query(sql, new BeanPropertyRowMapper<Notify>(Notify.class));
return notifys;
return notifys; // 返回查询结果
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 打印异常堆栈信息
return null; // 查询失败时返回 null
}
}
/**
* ID
* @param notifyid ID
*/
@Override
public void deleteNotifyById(String notifyid) {
try {
// SQL 语句:根据通知 ID 删除对应的通知记录
String sql = "delete from notify where id=?";
template.update(sql,notifyid);
// 使用 JdbcTemplate 执行删除操作
template.update(sql, notifyid);
} catch (DataAccessException e) {
e.printStackTrace();
e.printStackTrace(); // 打印异常堆栈信息
}
}
/**
*
* @return List null
*/
@Override
public List<Notify> findNotify() {
try {
// SQL 语句:查询最近三条通知记录
String sql = "select * from notify order by id DESC limit 3";
// 使用 JdbcTemplate 执行查询,并将结果映射为 Notify 对象列表
List<Notify> notify = template.query(sql, new BeanPropertyRowMapper<Notify>(Notify.class));
return notify;
return notify; // 返回查询结果
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 打印异常堆栈信息
return null; // 查询失败时返回 null
}
}
}

@ -1,44 +1,69 @@
package dao.impl;
import dao.PhotoDao;
import domain.Photo;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import utils.JDBCUtils;
// 引入相关类和接口
import dao.PhotoDao; // 数据访问对象DAO接口
import domain.Photo; // 表示 Photo 表数据结构的实体类
import org.springframework.dao.DataAccessException; // 数据访问异常类
import org.springframework.jdbc.core.BeanPropertyRowMapper; // 用于将结果集映射为实体类
import org.springframework.jdbc.core.JdbcTemplate; // Spring 的 JDBC 模板类
import utils.JDBCUtils; // 自定义工具类,用于获取数据源
/**
* PhotoDaoImpl PhotoDao Photo
*/
public class PhotoDaoImpl implements PhotoDao {
// 使用 JdbcTemplate 进行数据库操作,通过 JDBCUtils 获取数据源
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
/**
*
* @param photo Photo
*/
@Override
public void addPhoto(Photo photo) {
try {
String sql = "insert into photo(photo_id,photo_name) values(?,?)";
template.update(sql,photo.getPhotoId(),photo.getPhotoName());
// SQL 语句:向 photo 表插入照片记录
String sql = "insert into photo(photo_id, photo_name) values(?, ?)";
// 使用 JdbcTemplate 执行插入操作
template.update(sql, photo.getPhotoId(), photo.getPhotoName());
} catch (DataAccessException e) {
e.printStackTrace();
e.printStackTrace(); // 打印异常堆栈信息
}
}
/**
* ID
* @param id ID
* @return Photo null
*/
@Override
public Photo findPhotoByPhotoId(String id) {
try {
// SQL 语句:根据照片 ID 查找对应的照片记录
String sql = "select * from photo where photo_id = ?";
Photo photo = template.queryForObject(sql,new BeanPropertyRowMapper<Photo>(Photo.class),id);
return photo;
// 使用 JdbcTemplate 执行查询,并将结果映射为 Photo 对象
Photo photo = template.queryForObject(sql, new BeanPropertyRowMapper<Photo>(Photo.class), id);
return photo; // 返回查询结果
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 打印异常堆栈信息
return null; // 查询失败时返回 null
}
}
/**
*
* @param photo Photo
*/
@Override
public void updatePhoto(Photo photo) {
try {
String sql = "update photo set photo_name=? where photo_id=?";
template.update(sql,photo.getPhotoName(),photo.getPhotoId());
// SQL 语句:更新 photo 表中的照片名称
String sql = "update photo set photo_name = ? where photo_id = ?";
// 使用 JdbcTemplate 执行更新操作
template.update(sql, photo.getPhotoName(), photo.getPhotoId());
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(); // 打印异常堆栈信息
}
}
}

@ -1,53 +1,81 @@
package dao.impl;
import dao.SelectCourseDao;
import domain.SelectCourse;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import utils.JDBCUtils;
// 引入相关类和接口
import dao.SelectCourseDao; // 数据访问对象DAO接口
import domain.SelectCourse; // 表示 SelectCourse 表数据结构的实体类
import org.springframework.dao.DataAccessException; // 数据访问异常类
import org.springframework.jdbc.core.BeanPropertyRowMapper; // 用于将结果集映射为实体类
import org.springframework.jdbc.core.JdbcTemplate; // Spring 的 JDBC 模板类
import utils.JDBCUtils; // 自定义工具类,用于获取数据源
import java.util.List;
import java.util.List; // Java 的 List 接口
/**
* SelectCourseDaoImpl SelectCourseDao select_course
*/
public class SelectCourseDaoImpl implements SelectCourseDao {
// 使用 JdbcTemplate 进行数据库操作,通过 JDBCUtils 获取数据源
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
/**
* ID
* @param cid ID
* @return List null
*/
@Override
public List<SelectCourse> findStudentSelectedCourseByCourseId(String cid) {
try {
String sql = "select course.c_id,course.c_name,course.c_info,student.s_id,student.s_name,select_course.score\n" +
"from select_course,student,course\n" +
"where student.s_id=select_course.s_id\n" +
"and select_course.c_id=course.c_id\n" +
"and select_course.c_id=?";
List<SelectCourse> scs = template.query(sql, new BeanPropertyRowMapper<SelectCourse>(SelectCourse.class),cid);
return scs;
// SQL 语句:查询选修该课程的所有学生及成绩信息
String sql = "select course.c_id, course.c_name, course.c_info, student.s_id, student.s_name, select_course.score\n" +
"from select_course, student, course\n" +
"where student.s_id = select_course.s_id\n" +
"and select_course.c_id = course.c_id\n" +
"and select_course.c_id = ?";
// 使用 JdbcTemplate 执行查询,并将结果映射为 SelectCourse 对象列表
List<SelectCourse> scs = template.query(sql, new BeanPropertyRowMapper<SelectCourse>(SelectCourse.class), cid);
return scs; // 返回查询结果
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 打印异常堆栈信息
return null; // 查询失败时返回 null
}
}
/**
* ID ID
* @param cid ID
* @param sid ID
* @return SelectCourse null
*/
@Override
public SelectCourse findScoreByCourseIdAndStudentId(String cid, String sid) {
try {
String sql = "select * from select_course where c_id=? and s_id=?";
// SQL 语句:查询指定课程和学生的选课记录
String sql = "select * from select_course where c_id = ? and s_id = ?";
// 使用 JdbcTemplate 执行查询,并将结果映射为 SelectCourse 对象
SelectCourse sc = template.queryForObject(sql, new BeanPropertyRowMapper<SelectCourse>(SelectCourse.class), cid, sid);
return sc;
} catch (
DataAccessException e) {
e.printStackTrace();
return null;
return sc; // 返回查询结果
} catch (DataAccessException e) {
e.printStackTrace(); // 打印异常堆栈信息
return null; // 查询失败时返回 null
}
}
/**
* ID ID
* @param cid ID
* @param sid ID
* @param sScore
*/
@Override
public void upDateScoreByCidAndSid(String cid, String sid, String sScore) {
try {
// SQL 语句:根据课程 ID 和学生 ID 更新成绩
String sql = "update select_course set score = ? where c_id = ? and s_id = ?";
template.update(sql,sScore,cid,sid);
// 使用 JdbcTemplate 执行更新操作
template.update(sql, sScore, cid, sid);
} catch (DataAccessException e) {
e.printStackTrace();
e.printStackTrace(); // 打印异常堆栈信息
}
}
}

@ -1,233 +1,318 @@
package dao.impl;
import dao.StudentDao;
import domain.Course;
import domain.SelectCourse;
import domain.Student;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import utils.JDBCUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
// 引入相关类和接口
import dao.StudentDao; // StudentDao 接口,定义学生相关的数据访问方法
import domain.Course; // Course 实体类,表示课程数据
import domain.SelectCourse; // SelectCourse 实体类,表示学生选课信息
import domain.Student; // Student 实体类,表示学生数据
import org.springframework.dao.DataAccessException; // 数据访问异常
import org.springframework.jdbc.core.BeanPropertyRowMapper; // 将查询结果映射为 Java 对象
import org.springframework.jdbc.core.JdbcTemplate; // JDBC 操作模板
import utils.JDBCUtils; // 自定义工具类,用于获取数据库数据源
import java.util.ArrayList; // ArrayList 类,用于存储参数和结果
import java.util.List; // List 接口,表示列表
import java.util.Map; // Map 接口,用于存储查询条件
import java.util.Set; // Set 接口,用于存储条件的键集合
/**
* StudentDaoImpl StudentDao
*/
public class StudentDaoImpl implements StudentDao {
// 使用 JdbcTemplate 来简化数据库操作JDBCUtils 提供数据源
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
/**
*
* @return List null
*/
@Override
public List<Student> findAll() {
//使用JDBC操作数据库
try {
// SQL 语句:查询所有学生
String sql = "select * from student";
// 执行查询并返回结果,使用 BeanPropertyRowMapper 将结果映射为 Student 实体类
List<Student> students = template.query(sql, new BeanPropertyRowMapper<Student>(Student.class));
return students;
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 捕获并打印异常堆栈
return null; // 查询失败时返回 null
}
}
/**
* ID
* @param id ID
* @param password
* @return null
*/
@Override
public Student findStudentidAndPassword(String id,String password) {
public Student findStudentidAndPassword(String id, String password) {
try {
// SQL 语句:根据学生 ID 和密码查询学生
String sql = "select * from student where s_id = ? and s_password = ?";
Student student = template.queryForObject(sql,new BeanPropertyRowMapper<Student>(Student.class),id,password);
// 执行查询并返回结果
Student student = template.queryForObject(sql, new BeanPropertyRowMapper<Student>(Student.class), id, password);
return student;
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 捕获并打印异常堆栈
return null; // 查询失败时返回 null
}
}
/**
* ID
* @param id ID
* @return null
*/
@Override
public Student findStudentById(String id) {
try {
// SQL 语句:根据学生 ID 查询学生信息
String sql = "select * from student where s_id = ?";
Student student = template.queryForObject(sql,new BeanPropertyRowMapper<Student>(Student.class),id);
// 执行查询并返回结果
Student student = template.queryForObject(sql, new BeanPropertyRowMapper<Student>(Student.class), id);
return student;
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 捕获并打印异常堆栈
return null; // 查询失败时返回 null
}
}
/**
*
* @param student
*/
@Override
public void addStudent(Student student) {
try {
String sql = "insert into student(s_id,s_password) values(?,?)";
template.update(sql,student.getS_id(),student.getS_password());
// SQL 语句:插入学生数据
String sql = "insert into student(s_id, s_password) values(?, ?)";
// 执行插入操作
template.update(sql, student.getS_id(), student.getS_password());
} catch (DataAccessException e) {
e.printStackTrace();
e.printStackTrace(); // 捕获并打印异常堆栈
}
}
/**
*
* @param student
*/
@Override
public void updateInfo(Student student) {
try {
String sql = "update student set s_name =?,s_sex=?,s_age=?,s_phone=?,s_email=?,s_address=?,s_college=?,s_department=?,s_class=? where s_id=?";
template.update(sql,student.getS_name(),student.getS_sex(),student.getS_age(),student.getS_phone(),student.getS_email(),student.getS_address(),student.getS_college(),student.getS_department(),student.getS_class(),student.getS_id());
// SQL 语句:更新学生信息
String sql = "update student set s_name = ?, s_sex = ?, s_age = ?, s_phone = ?, s_email = ?, s_address = ?, s_college = ?, s_department = ?, s_class = ? where s_id = ?";
// 执行更新操作
template.update(sql, student.getS_name(), student.getS_sex(), student.getS_age(),
student.getS_phone(), student.getS_email(), student.getS_address(),
student.getS_college(), student.getS_department(), student.getS_class(), student.getS_id());
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(); // 捕获并打印异常堆栈
}
}
/**
*
* @param studentid ID
* @param newpassword
*/
@Override
public void updatePassword(String studentid, String newpassword) {
try {
String sql = "update student set s_password=? where s_id=?";
template.update(sql,newpassword,studentid);
// SQL 语句:更新学生密码
String sql = "update student set s_password = ? where s_id = ?";
// 执行更新操作
template.update(sql, newpassword, studentid);
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(); // 捕获并打印异常堆栈
}
}
/**
*
* @param studentid ID
* @return List null
*/
@Override
public List<SelectCourse> findAllSelectCourse(String studentid) {
try {
String sql = "select student.s_id,student.s_name,course.c_id,course.c_name,course.c_info,teacher.t_id,t_name,select_course.score\n" +
"from select_course,student,course,teacher\n" +
"where student.s_id=select_course.s_id\n" +
"and select_course.c_id=course.c_id\n" +
"and course.t_id=teacher.t_id\n" +
"and student.s_id=?";
List<SelectCourse> scs = template.query(sql, new BeanPropertyRowMapper<SelectCourse>(SelectCourse.class),studentid);
// SQL 语句:查询学生的所有选课信息
String sql = "select student.s_id, student.s_name, course.c_id, course.c_name, course.c_info, teacher.t_id, t_name, select_course.score " +
"from select_course, student, course, teacher " +
"where student.s_id = select_course.s_id " +
"and select_course.c_id = course.c_id " +
"and course.t_id = teacher.t_id " +
"and student.s_id = ?";
// 执行查询并返回结果
List<SelectCourse> scs = template.query(sql, new BeanPropertyRowMapper<SelectCourse>(SelectCourse.class), studentid);
return scs;
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 捕获并打印异常堆栈
return null; // 查询失败时返回 null
}
}
/**
*
* @return List null
*/
@Override
public List<Course> findAllOptionalCourse() {
try {
String sql = "select course.c_id,course.c_name,course.c_info,teacher.t_id,t_name\n" +
"from course,teacher\n" +
"where course.t_id=teacher.t_id";
// SQL 语句:查询所有可选课程
String sql = "select course.c_id, course.c_name, course.c_info, teacher.t_id, t_name " +
"from course, teacher " +
"where course.t_id = teacher.t_id";
// 执行查询并返回结果
List<Course> cs = template.query(sql, new BeanPropertyRowMapper<Course>(Course.class));
return cs;
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 捕获并打印异常堆栈
return null; // 查询失败时返回 null
}
}
/**
*
* @param studentid ID
* @param courseid ID
*/
@Override
public void addSelectCourse(String studentid, String courseid) {
try {
String sql = "insert into select_course(s_id,c_id) values(?,?)";
template.update(sql,studentid,courseid);
// SQL 语句:学生选修课程
String sql = "insert into select_course(s_id, c_id) values(?, ?)";
// 执行插入操作
template.update(sql, studentid, courseid);
} catch (DataAccessException e) {
e.printStackTrace();
e.printStackTrace(); // 捕获并打印异常堆栈
}
}
/**
* ID
* @param studentid ID
*/
@Override
public void deleteStudentById(String studentid) {
try {
String sql = "delete from student where s_id=?";
template.update(sql,studentid);
// SQL 语句:删除学生
String sql = "delete from student where s_id = ?";
// 执行删除操作
template.update(sql, studentid);
} catch (DataAccessException e) {
e.printStackTrace();
e.printStackTrace(); // 捕获并打印异常堆栈
}
}
/**
*
* @param condition
* @return
*/
@Override
public int findTotalCount(Map<String, String[]> condition) {
//定义模板初始化sql
String sql = "select count(*) from student where 1=1";
// 初始化 SQL 语句
String sql = "select count(*) from student where 1 = 1";
StringBuilder sb = new StringBuilder(sql);
//遍历map
List<Object> params = new ArrayList<Object>(); // 存储查询参数
// 遍历查询条件
Set<String> keySet = condition.keySet();
//定义参数集合
List<Object> params = new ArrayList<Object>();
for (String key : keySet) {
System.out.println(key);
//排除分页条件参数
// 排除分页相关的参数
if ("currentPage".equals(key) || "rows".equals(key)) {
continue;
}
//获取value
String value = condition.get(key)[0];
//判断value是否有值
if (value != null && !"".equals(value)) {
//有值
sb.append(" and "+key+" like ? ");
params.add("%"+value+"%");//?条件的值
// 添加条件到 SQL 语句
sb.append(" and " + key + " like ? ");
params.add("%" + value + "%"); // ? 条件的值
}
}
System.out.println(sb.toString());
System.out.println(params);
return template.queryForObject(sb.toString(),Integer.class,params.toArray());
// 执行查询并返回结果
return template.queryForObject(sb.toString(), Integer.class, params.toArray());
}
/**
*
* @param s
*/
@Override
public void addStudentAllInfo(Student s) {
try {
String sql = "insert into student(s_id,s_college,s_department,s_class,s_name,s_sex,s_age,s_phone,s_email,s_address) values(?,?,?,?,?,?,?,?,?,?)";
template.update(sql,s.getS_id(),s.getS_college(),s.getS_department(),s.getS_class(),s.getS_name(),s.getS_sex(),s.getS_age(),s.getS_phone(),s.getS_email(),s.getS_address());
// SQL 语句:插入学生所有信息
String sql = "insert into student(s_id, s_college, s_department, s_class, s_name, s_sex, s_age, s_phone, s_email, s_address) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
// 执行插入操作
template.update(sql, s.getS_id(), s.getS_college(), s.getS_department(), s.getS_class(), s.getS_name(),
s.getS_sex(), s.getS_age(), s.getS_phone(), s.getS_email(), s.getS_address());
} catch (DataAccessException e) {
e.printStackTrace();
e.printStackTrace(); // 捕获并打印异常堆栈
}
}
/**
*
* @return null
*/
@Override
public List<SelectCourse> findSelectCourseAllStudent() {
try {
String sql = "select student.s_id,student.s_name,course.c_id,course.c_name,course.c_info,teacher.t_id,t_name,select_course.score\n" +
"from select_course,student,course,teacher\n" +
"where student.s_id=select_course.s_id\n" +
"and select_course.c_id=course.c_id\n" +
"and course.t_id=teacher.t_id\n";
// SQL 语句:查询所有学生的选课信息
String sql = "select student.s_id, student.s_name, course.c_id, course.c_name, course.c_info, teacher.t_id, t_name, select_course.score " +
"from select_course, student, course, teacher " +
"where student.s_id = select_course.s_id " +
"and select_course.c_id = course.c_id " +
"and course.t_id = teacher.t_id";
// 执行查询并返回结果
List<SelectCourse> scs = template.query(sql, new BeanPropertyRowMapper<SelectCourse>(SelectCourse.class));
return scs;
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 捕获并打印异常堆栈
return null; // 查询失败时返回 null
}
}
/**
*
* @param start
* @param rows
* @param condition
* @return
*/
@Override
public List<Student> findByPage(int start, int rows, Map<String, String[]> condition) {
try {
String sql = "select * from student where 1=1";
// 初始化 SQL 语句
String sql = "select * from student where 1 = 1";
StringBuilder sb = new StringBuilder(sql);
//遍历map
List<Object> params = new ArrayList<Object>(); // 存储查询参数
// 遍历查询条件
Set<String> keySet = condition.keySet();
//定义参数集合
List<Object> params = new ArrayList<Object>();
for (String key : keySet) {
//排除分页条件参数
// 排除分页相关的参数
if ("currentPage".equals(key) || "rows".equals(key)) {
continue;
}
//获取value
String value = condition.get(key)[0];
//判断value是否有值
if (value != null && !"".equals(value)) {
//有值
sb.append(" and "+key+" like ? ");
params.add("%"+value+"%");//?条件的值
// 添加条件到 SQL 语句
sb.append(" and " + key + " like ? ");
params.add("%" + value + "%"); // ? 条件的值
}
}
//添加分页查询
sb.append(" limit ? , ?");
//添加分页查询参数值
// 添加分页条件
sb.append(" limit ?, ?");
params.add(start);
params.add(rows);
System.out.println(sb.toString());
System.out.println(params);
return template.query(sb.toString(),new BeanPropertyRowMapper<Student>(Student.class),params.toArray());
// 执行查询并返回结果
return template.query(sb.toString(), new BeanPropertyRowMapper<Student>(Student.class), params.toArray());
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 捕获并打印异常堆栈
return null; // 查询失败时返回 null
}
}
}

@ -1,137 +1,213 @@
package dao.impl;
import dao.TeacherDao;
import domain.Course;
import domain.Student;
import domain.Teacher;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import utils.JDBCUtils;
// 引入相关类和接口
import dao.TeacherDao; // TeacherDao 接口,定义教师相关的数据访问方法
import domain.Course; // Course 实体类,表示课程数据
import domain.Teacher; // Teacher 实体类,表示教师数据
import org.springframework.dao.DataAccessException; // 数据访问异常
import org.springframework.jdbc.core.BeanPropertyRowMapper; // 将查询结果映射为 Java 对象
import org.springframework.jdbc.core.JdbcTemplate; // JDBC 操作模板
import utils.JDBCUtils; // 自定义工具类,用于获取数据库数据源
import java.util.List;
import java.util.List; // List 接口,表示列表
/**
* TeacherDaoImpl TeacherDao
*/
public class TeacherDaoImpl implements TeacherDao {
// 使用 JdbcTemplate 来简化数据库操作JDBCUtils 提供数据源
private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
/**
* ID
* @param id ID
* @param password
* @return null
*/
@Override
public Teacher findTeacheridAndPassword(String id, String password) {
try {
// SQL 语句:根据教师 ID 和密码查询教师
String sql = "select * from teacher where t_id = ? and t_password = ?";
Teacher teacher = template.queryForObject(sql,new BeanPropertyRowMapper<Teacher>(Teacher.class),id,password);
// 执行查询并返回结果
Teacher teacher = template.queryForObject(sql, new BeanPropertyRowMapper<Teacher>(Teacher.class), id, password);
return teacher;
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 捕获并打印异常堆栈
return null; // 查询失败时返回 null
}
}
/**
*
* @return List null
*/
@Override
public List<Teacher> findAll() {
try {
// SQL 语句:查询所有教师
String sql = "select * from teacher";
// 执行查询并返回结果
List<Teacher> teachers = template.query(sql, new BeanPropertyRowMapper<Teacher>(Teacher.class));
return teachers;
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 捕获并打印异常堆栈
return null; // 查询失败时返回 null
}
}
/**
*
* @param t_id ID
* @return null
*/
@Override
public List<Course> findMySelfOptionalCourse(String t_id) {
try {
// SQL 语句:查询教师教授的课程
String sql = "select * from course where t_id = ?";
List<Course> courses = template.query(sql, new BeanPropertyRowMapper<Course>(Course.class),t_id);
// 执行查询并返回结果
List<Course> courses = template.query(sql, new BeanPropertyRowMapper<Course>(Course.class), t_id);
return courses;
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 捕获并打印异常堆栈
return null; // 查询失败时返回 null
}
}
/**
* ID
* @param cid ID
* @return null
*/
@Override
public Course findOptionalCourseByCourseId(String cid) {
try {
// SQL 语句:根据课程 ID 查询课程信息
String sql = "select * from course where c_id = ?";
Course c = template.queryForObject(sql,new BeanPropertyRowMapper<Course>(Course.class),cid);
return c;
// 执行查询并返回结果
Course course = template.queryForObject(sql, new BeanPropertyRowMapper<Course>(Course.class), cid);
return course;
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 捕获并打印异常堆栈
return null; // 查询失败时返回 null
}
}
/**
*
* @param updateCourse
*/
@Override
public void updateCourseInfo(Course updateCourse) {
try {
String sql = "update course set c_name =?,c_info=? where c_id=?";
template.update(sql,updateCourse.getC_name(),updateCourse.getC_info(),updateCourse.getC_id());
// SQL 语句:更新课程信息
String sql = "update course set c_name = ?, c_info = ? where c_id = ?";
// 执行更新操作
template.update(sql, updateCourse.getC_name(), updateCourse.getC_info(), updateCourse.getC_id());
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(); // 捕获并打印异常堆栈
}
}
/**
* ID
* @param cid ID
*/
@Override
public void deleteCourseById(String cid) {
try {
String sql = "delete from course where c_id=?";
template.update(sql,cid);
// SQL 语句:删除课程
String sql = "delete from course where c_id = ?";
// 执行删除操作
template.update(sql, cid);
} catch (DataAccessException e) {
e.printStackTrace();
e.printStackTrace(); // 捕获并打印异常堆栈
}
}
/**
*
* @param teacherid ID
* @param newpassword
*/
@Override
public void updatePassword(String teacherid, String newpassword) {
try {
String sql = "update teacher set t_password=? where t_id=?";
template.update(sql,newpassword,teacherid);
// SQL 语句:更新教师密码
String sql = "update teacher set t_password = ? where t_id = ?";
// 执行更新操作
template.update(sql, newpassword, teacherid);
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(); // 捕获并打印异常堆栈
}
}
/**
* ID
* @param t_id ID
* @return null
*/
@Override
public Teacher findTeacherById(String t_id) {
try {
// SQL 语句:根据教师 ID 查询教师信息
String sql = "select * from teacher where t_id = ?";
Teacher teacher = template.queryForObject(sql,new BeanPropertyRowMapper<Teacher>(Teacher.class),t_id);
// 执行查询并返回结果
Teacher teacher = template.queryForObject(sql, new BeanPropertyRowMapper<Teacher>(Teacher.class), t_id);
return teacher;
} catch (DataAccessException e) {
e.printStackTrace();
return null;
e.printStackTrace(); // 捕获并打印异常堆栈
return null; // 查询失败时返回 null
}
}
/**
*
* @param teacher
*/
@Override
public void addTeacherAllInfo(Teacher t) {
public void addTeacherAllInfo(Teacher teacher) {
try {
String sql = "insert into teacher(t_id,t_name,t_sex,t_education,t_title) values(?,?,?,?,?)";
template.update(sql,t.getT_id(),t.getT_name(),t.getT_sex(),t.getT_education(),t.getT_title());
// SQL 语句:插入教师信息
String sql = "insert into teacher(t_id, t_name, t_sex, t_education, t_title) values(?, ?, ?, ?, ?)";
// 执行插入操作
template.update(sql, teacher.getT_id(), teacher.getT_name(), teacher.getT_sex(), teacher.getT_education(), teacher.getT_title());
} catch (DataAccessException e) {
e.printStackTrace();
e.printStackTrace(); // 捕获并打印异常堆栈
}
}
/**
* ID
* @param teacherid ID
*/
@Override
public void deleteTeacherById(String teacherid) {
try {
String sql = "delete from teacher where t_id=?";
template.update(sql,teacherid);
// SQL 语句:删除教师
String sql = "delete from teacher where t_id = ?";
// 执行删除操作
template.update(sql, teacherid);
} catch (DataAccessException e) {
e.printStackTrace();
e.printStackTrace(); // 捕获并打印异常堆栈
}
}
/**
*
* @param teacher
*/
@Override
public void updateInfo(Teacher t) {
public void updateInfo(Teacher teacher) {
try {
String sql = "update teacher set t_name =?,t_sex=?,t_education=?,t_title=? where t_id=?";
template.update(sql,t.getT_name(),t.getT_sex(),t.getT_education(),t.getT_title(),t.getT_id());
// SQL 语句:更新教师信息
String sql = "update teacher set t_name = ?, t_sex = ?, t_education = ?, t_title = ? where t_id = ?";
// 执行更新操作
template.update(sql, teacher.getT_name(), teacher.getT_sex(), teacher.getT_education(), teacher.getT_title(), teacher.getT_id());
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(); // 捕获并打印异常堆栈
}
}
}

@ -1,25 +1,54 @@
package domain;
package domain; // 定义在 domain 包下,表示该类是领域对象类,用于存储管理员信息。
/**
*
*
*/
public class Admin {
private String a_id;
private String a_password;
private String a_id; // 管理员工号
private String a_password; // 管理员密码
/**
*
*
* @return
*/
public String getA_id() {
return a_id;
}
/**
*
*
* @param a_id
*/
public void setA_id(String a_id) {
this.a_id = a_id;
}
/**
*
*
* @return
*/
public String getA_password() {
return a_password;
}
/**
*
*
* @param a_password
*/
public void setA_password(String a_password) {
this.a_password = a_password;
}
/**
* toString
*
* @return
*/
@Override
public String toString() {
return "Admin{" +
@ -28,3 +57,4 @@ public class Admin {
'}';
}
}

@ -1,35 +1,74 @@
package domain;
package domain; // 定义在 domain 包下,表示该类是领域对象类,用于存储学院、系、班级等信息。
/**
* CDC
*
*/
public class CDC {
private String college;
private String department;
private String cclass;
private String college; // 学院名称
private String department; // 系名称
private String cclass; // 班级名称
/**
*
*
* @return
*/
public String getCollege() {
return college;
}
/**
*
*
* @param college
*/
public void setCollege(String college) {
this.college = college;
}
/**
*
*
* @return
*/
public String getDepartment() {
return department;
}
/**
*
*
* @param department
*/
public void setDepartment(String department) {
this.department = department;
}
/**
*
*
* @return
*/
public String getCclass() {
return cclass;
}
/**
*
*
* @param cclass
*/
public void setCclass(String cclass) {
this.cclass = cclass;
}
/**
* toString
*
* @return
*/
@Override
public String toString() {
return "CDC{" +

@ -1,34 +1,74 @@
package domain;
package domain; // 定义在 domain 包下,表示该类是领域对象类,用于存储投诉信息。
/**
* Complaint
* ID
*/
public class Complaint {
private String id;
private String cdate;
private String content;
private String id; // 投诉ID
private String cdate; // 投诉日期
private String content; // 投诉内容
/**
* ID
*
* @return ID
*/
public String getId() {
return id;
}
/**
* ID
*
* @param id ID
*/
public void setId(String id) {
this.id = id;
}
/**
*
*
* @return
*/
public String getCdate() {
return cdate;
}
/**
*
*
* @param cdate
*/
public void setCdate(String cdate) {
this.cdate = cdate;
}
/**
*
*
* @return
*/
public String getContent() {
return content;
}
/**
*
*
* @param content
*/
public void setContent(String content) {
this.content = content;
}
/**
* toString ID
*
* @return ID
*/
@Override
public String toString() {
return "Complaint{" +

@ -1,60 +1,80 @@
package domain;
package domain; // 定义在 domain 包下,表示该类是领域对象类,用于存储投诉信息。
public class Course {
private String c_id;
private String c_name;
private String c_info;
private String t_id;
private String t_name;
/**
* Complaint
* ID
*/
public class Complaint {
public String getC_id() {
return c_id;
}
public void setC_id(String c_id) {
this.c_id = c_id;
}
public String getC_name() {
return c_name;
}
public void setC_name(String c_name) {
this.c_name = c_name;
}
private String id; // 投诉ID
private String cdate; // 投诉日期
private String content; // 投诉内容
public String getC_info() {
return c_info;
/**
* ID
*
* @return ID
*/
public String getId() {
return id;
}
public void setC_info(String c_info) {
this.c_info = c_info;
/**
* ID
*
* @param id ID
*/
public void setId(String id) {
this.id = id;
}
public String getT_id() {
return t_id;
/**
*
*
* @return
*/
public String getCdate() {
return cdate;
}
public void setT_id(String t_id) {
this.t_id = t_id;
/**
*
*
* @param cdate
*/
public void setCdate(String cdate) {
this.cdate = cdate;
}
public String getT_name() {
return t_name;
/**
*
*
* @return
*/
public String getContent() {
return content;
}
public void setT_name(String t_name) {
this.t_name = t_name;
/**
*
*
* @param content
*/
public void setContent(String content) {
this.content = content;
}
@Override
/**
* toString ID
*
* @return ID
*/
@Override
public String toString() {
return "Course{" +
"c_id='" + c_id + '\'' +
", c_name='" + c_name + '\'' +
", c_info='" + c_info + '\'' +
", t_id='" + t_id + '\'' +
", t_name='" + t_name + '\'' +
return "Complaint{" +
"id='" + id + '\'' +
", cdate='" + cdate + '\'' +
", content='" + content + '\'' +
'}';
}
}

@ -1,34 +1,74 @@
package domain;
package domain; // 定义在 domain 包下,表示该类是领域对象类,用于存储文件信息。
/**
* FileClass
*
*/
public class FileClass {
private String fileName;
private String filePath;
private String fileSize;
private String fileName; // 文件名
private String filePath; // 文件路径
private String fileSize; // 文件大小
/**
*
*
* @return
*/
public String getFileName() {
return fileName;
}
/**
*
*
* @param fileName
*/
public void setFileName(String fileName) {
this.fileName = fileName;
}
/**
*
*
* @return
*/
public String getFilePath() {
return filePath;
}
/**
*
*
* @param filePath
*/
public void setFilePath(String filePath) {
this.filePath = filePath;
}
/**
*
*
* @return
*/
public String getFileSize() {
return fileSize;
}
/**
*
*
* @param fileSize
*/
public void setFileSize(String fileSize) {
this.fileSize = fileSize;
}
/**
* toString
*
* @return
*/
@Override
public String toString() {
return "FileClass{" +

@ -1,35 +1,74 @@
package domain;
package domain; // 定义在 domain 包下,表示该类是领域对象类,用于存储通知信息。
/**
* Notify
* ID
*/
public class Notify {
private String id;
private String notifyInfo;
private String notifyDate;
private String id; // 通知ID
private String notifyInfo; // 通知内容
private String notifyDate; // 通知日期
/**
* ID
*
* @return ID
*/
public String getId() {
return id;
}
/**
* ID
*
* @param id ID
*/
public void setId(String id) {
this.id = id;
}
/**
*
*
* @return
*/
public String getNotifyInfo() {
return notifyInfo;
}
/**
*
*
* @param notifyInfo
*/
public void setNotifyInfo(String notifyInfo) {
this.notifyInfo = notifyInfo;
}
/**
*
*
* @return
*/
public String getNotifyDate() {
return notifyDate;
}
/**
*
*
* @param notifyDate
*/
public void setNotifyDate(String notifyDate) {
this.notifyDate = notifyDate;
}
/**
* toString ID
*
* @return ID
*/
@Override
public String toString() {
return "Notify{" +

@ -1,57 +1,115 @@
package domain;
package domain; // 定义在 domain 包下,表示该类是领域对象类,用于存储分页信息。
import java.util.List;
/**
*
* PageBean
*
* T
*/
public class PageBean<T> {
private int totalCount; //总记录数
private int totalPage; //总页码
private List<T> list; //每页数据
private int currentPage; //当前页码
private int rows; //每页显示的记录数
private int totalCount; // 总记录数
private int totalPage; // 总页码数
private List<T> list; // 当前页的数据
private int currentPage; // 当前页码
private int rows; // 每页显示的记录数
/**
*
*
* @return
*/
public int getTotalCount() {
return totalCount;
}
/**
*
*
* @param totalCount
*/
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
/**
*
*
* @return
*/
public int getTotalPage() {
return totalPage;
}
/**
*
*
* @param totalPage
*/
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
/**
*
*
* @return
*/
public List<T> getList() {
return list;
}
/**
*
*
* @param list
*/
public void setList(List<T> list) {
this.list = list;
}
/**
*
*
* @return
*/
public int getCurrentPage() {
return currentPage;
}
/**
*
*
* @param currentPage
*/
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
/**
*
*
* @return
*/
public int getRows() {
return rows;
}
/**
*
*
* @param rows
*/
public void setRows(int rows) {
this.rows = rows;
}
/**
* toString
*
* @return
*/
@Override
public String toString() {
return "PageBean{" +

@ -1,22 +1,46 @@
package domain;
package domain; // 定义在 domain 包下,表示该类是领域对象类,用于存储照片信息。
/**
* Photo
* ID
*/
public class Photo {
private String photoId;
private String photoName;
private String photoId; // 照片ID
private String photoName; // 照片名称
/**
* ID
*
* @return ID
*/
public String getPhotoId() {
return photoId;
}
/**
* ID
*
* @param photoId ID
*/
public void setPhotoId(String photoId) {
this.photoId = photoId;
}
/**
*
*
* @return
*/
public String getPhotoName() {
return photoName;
}
/**
*
*
* @param photoName
*/
public void setPhotoName(String photoName) {
this.photoName = photoName;
}

@ -1,79 +1,169 @@
package domain;
package domain; // 定义在 domain 包下,表示该类是领域对象类,用于存储学生选课信息。
/**
* SelectCourse
* IDID
*/
public class SelectCourse {
private String s_id;
private String s_name;
private String c_id;
private String c_name;
private String c_info;
private String t_id;
private String t_name;
private String score;
private String s_id; // 学生ID
private String s_name; // 学生姓名
private String c_id; // 课程ID
private String c_name; // 课程名称
private String c_info; // 课程信息
private String t_id; // 教师ID
private String t_name; // 教师姓名
private String score; // 学生的课程成绩
/**
* ID
*
* @return ID
*/
public String getS_id() {
return s_id;
}
/**
* ID
*
* @param s_id ID
*/
public void setS_id(String s_id) {
this.s_id = s_id;
}
/**
*
*
* @return
*/
public String getS_name() {
return s_name;
}
/**
*
*
* @param s_name
*/
public void setS_name(String s_name) {
this.s_name = s_name;
}
/**
* ID
*
* @return ID
*/
public String getC_id() {
return c_id;
}
/**
* ID
*
* @param c_id ID
*/
public void setC_id(String c_id) {
this.c_id = c_id;
}
/**
*
*
* @return
*/
public String getC_name() {
return c_name;
}
/**
*
*
* @param c_name
*/
public void setC_name(String c_name) {
this.c_name = c_name;
}
/**
*
*
* @return
*/
public String getC_info() {
return c_info;
}
/**
*
*
* @param c_info
*/
public void setC_info(String c_info) {
this.c_info = c_info;
}
/**
* ID
*
* @return ID
*/
public String getT_id() {
return t_id;
}
/**
* ID
*
* @param t_id ID
*/
public void setT_id(String t_id) {
this.t_id = t_id;
}
/**
*
*
* @return
*/
public String getT_name() {
return t_name;
}
/**
*
*
* @param t_name
*/
public void setT_name(String t_name) {
this.t_name = t_name;
}
/**
*
*
* @return
*/
public String getScore() {
return score;
}
/**
*
*
* @param score
*/
public void setScore(String score) {
this.score = score;
}
/**
* toString
*
* @return IDIDID
*/
@Override
public String toString() {
return "SelectCourse{" +

@ -1,106 +1,226 @@
package domain;
package domain; // 定义在 domain 包下,表示该类是领域对象类,用于存储学生的个人信息。
/**
* Student
* ID
*/
public class Student {
private String s_id;
private String s_college;
private String s_department;
private String s_class;
private String s_name;
private String s_sex;
private String s_age;
private String s_address;
private String s_phone;
private String s_email;
private String s_password;
private String s_id; // 学生ID
private String s_college; // 学院名称
private String s_department; // 学院下的系别
private String s_class; // 所属班级
private String s_name; // 学生姓名
private String s_sex; // 学生性别
private String s_age; // 学生年龄
private String s_address; // 学生住址
private String s_phone; // 学生联系电话
private String s_email; // 学生电子邮件
private String s_password; // 学生登录密码
/**
* ID
*
* @return ID
*/
public String getS_id() {
return s_id;
}
/**
* ID
*
* @param s_id ID
*/
public void setS_id(String s_id) {
this.s_id = s_id;
}
/**
*
*
* @return
*/
public String getS_college() {
return s_college;
}
/**
*
*
* @param s_college
*/
public void setS_college(String s_college) {
this.s_college = s_college;
}
/**
*
*
* @return
*/
public String getS_department() {
return s_department;
}
/**
*
*
* @param s_department
*/
public void setS_department(String s_department) {
this.s_department = s_department;
}
/**
*
*
* @return
*/
public String getS_class() {
return s_class;
}
/**
*
*
* @param s_class
*/
public void setS_class(String s_class) {
this.s_class = s_class;
}
/**
*
*
* @return
*/
public String getS_name() {
return s_name;
}
/**
*
*
* @param s_name
*/
public void setS_name(String s_name) {
this.s_name = s_name;
}
/**
*
*
* @return
*/
public String getS_sex() {
return s_sex;
}
/**
*
*
* @param s_sex
*/
public void setS_sex(String s_sex) {
this.s_sex = s_sex;
}
/**
*
*
* @return
*/
public String getS_age() {
return s_age;
}
/**
*
*
* @param s_age
*/
public void setS_age(String s_age) {
this.s_age = s_age;
}
/**
*
*
* @return
*/
public String getS_address() {
return s_address;
}
/**
*
*
* @param s_address
*/
public void setS_address(String s_address) {
this.s_address = s_address;
}
/**
*
*
* @return
*/
public String getS_phone() {
return s_phone;
}
/**
*
*
* @param s_phone
*/
public void setS_phone(String s_phone) {
this.s_phone = s_phone;
}
/**
*
*
* @return
*/
public String getS_email() {
return s_email;
}
/**
*
*
* @param s_email
*/
public void setS_email(String s_email) {
this.s_email = s_email;
}
/**
*
*
* @return
*/
public String getS_password() {
return s_password;
}
/**
*
*
* @param s_password
*/
public void setS_password(String s_password) {
this.s_password = s_password;
}
/**
* toString
*
* @return ID
*/
@Override
public String toString() {
return "Student{" +

@ -1,61 +1,131 @@
package domain;
package domain; // 定义在 domain 包下,表示该类是领域对象类,用于存储教师的个人信息。
/**
* Teacher
* ID
*/
public class Teacher {
private String t_id;
private String t_name;
private String t_sex;
private String t_education;
private String t_title;
private String t_password;
private String t_id; // 教师ID
private String t_name; // 教师姓名
private String t_sex; // 教师性别
private String t_education; // 教师教育背景
private String t_title; // 教师职称
private String t_password; // 教师登录密码
/**
* ID
*
* @return ID
*/
public String getT_id() {
return t_id;
}
/**
* ID
*
* @param t_id ID
*/
public void setT_id(String t_id) {
this.t_id = t_id;
}
/**
*
*
* @return
*/
public String getT_name() {
return t_name;
}
/**
*
*
* @param t_name
*/
public void setT_name(String t_name) {
this.t_name = t_name;
}
/**
*
*
* @return
*/
public String getT_sex() {
return t_sex;
}
/**
*
*
* @param t_sex
*/
public void setT_sex(String t_sex) {
this.t_sex = t_sex;
}
/**
*
*
* @return
*/
public String getT_education() {
return t_education;
}
/**
*
*
* @param t_education
*/
public void setT_education(String t_education) {
this.t_education = t_education;
}
/**
*
*
* @return
*/
public String getT_title() {
return t_title;
}
/**
*
*
* @param t_title
*/
public void setT_title(String t_title) {
this.t_title = t_title;
}
/**
*
*
* @return
*/
public String getT_password() {
return t_password;
}
/**
*
*
* @param t_password
*/
public void setT_password(String t_password) {
this.t_password = t_password;
}
/**
* toString
*
* @return ID
*/
@Override
public String toString() {
return "Teacher{" +

@ -1,25 +1,48 @@
package service.impl;
import dao.AdminDao;
import dao.impl.AdminDaoImpl;
import domain.Admin;
import service.AdminService;
import dao.AdminDao; // 导入 AdminDao 接口,用于操作管理员相关的数据。
import dao.impl.AdminDaoImpl; // 导入 AdminDaoImpl 类,实际的管理员数据访问实现。
import domain.Admin; // 导入 Admin 类,表示管理员实体。
import service.AdminService; // 导入 AdminService 接口,定义管理员服务层的业务逻辑。
/**
* AdminServiceImpl
* AdminDao
*/
public class AdminServiceImpl implements AdminService {
private AdminDao dao = new AdminDaoImpl();
private AdminDao dao = new AdminDaoImpl(); // 实例化 AdminDaoImpl 对象,操作管理员数据。
/**
*
*
* @param admin ID
* @return null
*/
@Override
public Admin login(Admin admin) {
return dao.findAdminidAndPassword(admin.getA_id(),admin.getA_password());
return dao.findAdminidAndPassword(admin.getA_id(), admin.getA_password());
}
/**
*
*
* @param adminid ID
* @param newpassword
*/
@Override
public void updatePassword(String adminid, String newpassword) {
dao.updatePassword(adminid,newpassword);
dao.updatePassword(adminid, newpassword); // 调用 Dao 层方法更新密码。
}
/**
* ID
*
* @param admin ID
* @return null
*/
@Override
public Admin findAdminById(Admin admin) {
return dao.findAdminById(admin.getA_id());
return dao.findAdminById(admin.getA_id()); // 调用 Dao 层方法根据管理员ID查询信息。
}
}

@ -1,32 +1,57 @@
package service.impl;
import dao.CDCDao;
import dao.impl.CDCDaoImpl;
import domain.CDC;
import service.CDCService;
import dao.CDCDao; // 导入 CDCDao 接口,操作与 CDC学院、部门、班级相关的数据。
import dao.impl.CDCDaoImpl; // 导入 CDCDaoImpl 类,实际的 CDC 数据访问实现。
import domain.CDC; // 导入 CDC 类,表示学院、部门、班级等信息的实体。
import service.CDCService; // 导入 CDCService 接口,定义 CDC 服务层的业务逻辑。
import java.util.List;
import java.util.List; // 导入 List 类,作为返回的数据类型,用于返回多个结果。
/**
* CDCServiceImpl
* CDCDao
*/
public class CDCServiceImpl implements CDCService {
private CDCDao dao = new CDCDaoImpl();
private CDCDao dao = new CDCDaoImpl(); // 实例化 CDCDaoImpl 对象,用于操作 CDC 数据。
/**
*
*
* @return List
*/
@Override
public List<CDC> findAllCollege() {
return dao.findAllCollege();
return dao.findAllCollege(); // 调用 DAO 层方法获取所有学院数据。
}
/**
*
*
* @return List
*/
@Override
public List<CDC> findAllDepartment() {
return dao.findAllDepartment();
return dao.findAllDepartment(); // 调用 DAO 层方法获取所有部门数据。
}
/**
*
*
* @return List
*/
@Override
public List<CDC> findAllClass() {
return dao.findAllClass();
return dao.findAllClass(); // 调用 DAO 层方法获取所有班级数据。
}
/**
*
*
* @return List
*/
@Override
public List<CDC> findAll() {
return dao.findAll();
return dao.findAll(); // 调用 DAO 层方法获取所有学院、部门和班级数据。
}
}

@ -1,22 +1,37 @@
package service.impl;
import dao.ComplaintDao;
import dao.impl.ComplaintDaoImpl;
import domain.Complaint;
import service.ComplaintService;
import dao.ComplaintDao; // 导入 ComplaintDao 接口,操作与投诉相关的数据。
import dao.impl.ComplaintDaoImpl; // 导入 ComplaintDaoImpl 类,实际的 Complaint 数据访问实现。
import domain.Complaint; // 导入 Complaint 类,表示投诉信息的实体类。
import service.ComplaintService; // 导入 ComplaintService 接口,定义投诉服务层的业务逻辑。
import java.util.List;
import java.util.List; // 导入 List 类,作为返回的数据类型,用于返回多个结果。
/**
* ComplaintServiceImpl
* ComplaintDao
*/
public class ComplaintServiceImpl implements ComplaintService {
private ComplaintDao dao = new ComplaintDaoImpl();
private ComplaintDao dao = new ComplaintDaoImpl(); // 实例化 ComplaintDaoImpl 对象,用于操作投诉数据。
/**
*
*
* @return List
*/
@Override
public List<Complaint> findAll() {
return dao.findAllComplaint();
return dao.findAllComplaint(); // 调用 DAO 层方法获取所有投诉数据。
}
/**
*
*
* @param complaint
*/
@Override
public void addComplaint(Complaint complaint) {
dao.addComplaint(complaint);
dao.addComplaint(complaint); // 调用 DAO 层方法将投诉数据添加到数据库。
}
}

@ -1,24 +1,46 @@
package service.impl;
import dao.CourseDao;
import dao.impl.CourseDaoImpl;
import domain.Course;
import service.CourseService;
import dao.CourseDao; // 导入 CourseDao 接口,操作与课程相关的数据。
import dao.impl.CourseDaoImpl; // 导入 CourseDaoImpl 类,实际的 Course 数据访问实现。
import domain.Course; // 导入 Course 类,表示课程信息的实体类。
import service.CourseService; // 导入 CourseService 接口,定义课程服务层的业务逻辑。
/**
* CourseServiceImpl CourseService
* CourseDao
*/
public class CourseServiceImpl implements CourseService {
private CourseDao dao = new CourseDaoImpl();
private CourseDao dao = new CourseDaoImpl(); // 实例化 CourseDaoImpl 对象,用于操作课程数据。
/**
*
*
* @param course
*/
@Override
public void addOptionalCourse(Course course) {
dao.addOptionalCourse(course);
dao.addOptionalCourse(course); // 调用 DAO 层方法将课程信息添加到数据库。
}
/**
* ID
*
* @param cid ID
* @return Course
*/
@Override
public Course findSelectCourseByCourseId(String cid) {
return dao.findSelectCourseByCourseId(cid);
return dao.findSelectCourseByCourseId(cid); // 调用 DAO 层方法根据课程 ID 查询已选课程。
}
/**
*
*
* @param cid ID
*/
@Override
public void deleteServiceById(String cid) {
dao.deleteServiceById(cid);
dao.deleteServiceById(cid); // 调用 DAO 层方法删除课程信息。
}
}

@ -1,32 +1,57 @@
package service.impl;
import dao.NotifyDao;
import dao.impl.NotifyDaoImpl;
import domain.Notify;
import service.NotifyService;
import dao.NotifyDao; // 导入 NotifyDao 接口,操作通知相关的数据。
import dao.impl.NotifyDaoImpl; // 导入 NotifyDaoImpl 类,实际的 Notify 数据访问实现。
import domain.Notify; // 导入 Notify 类,表示通知信息的实体类。
import service.NotifyService; // 导入 NotifyService 接口,定义通知服务层的业务逻辑。
import java.util.List;
/**
* NotifyServiceImpl NotifyService
* NotifyDao
*/
public class NotifyServiceImpl implements NotifyService {
private NotifyDao dao = new NotifyDaoImpl();
private NotifyDao dao = new NotifyDaoImpl(); // 实例化 NotifyDaoImpl 对象,用于操作通知数据。
/**
*
*
* @param notify
*/
@Override
public void addNotify(Notify notify) {
dao.add(notify);
dao.add(notify); // 调用 DAO 层方法将通知信息添加到数据库。
}
/**
*
*
* @return
*/
@Override
public List<Notify> find() {
return dao.findNotify();
return dao.findNotify(); // 调用 DAO 层方法查询通知信息。
}
/**
*
*
* @return
*/
@Override
public List<Notify> findAll() {
return dao.findAllNotify();
return dao.findAllNotify(); // 调用 DAO 层方法查询所有通知信息。
}
/**
* ID
*
* @param notifyid ID
*/
@Override
public void deleteNotifyById(String notifyid) {
dao.deleteNotifyById(notifyid);
dao.deleteNotifyById(notifyid); // 调用 DAO 层方法删除指定通知 ID 的通知。
}
}

@ -1,25 +1,46 @@
package service.impl;
import dao.PhotoDao;
import dao.impl.PhotoDaoImpl;
import domain.Photo;
import service.PhotoService;
import dao.PhotoDao; // 导入 PhotoDao 接口,操作与照片相关的数据。
import dao.impl.PhotoDaoImpl; // 导入 PhotoDaoImpl 类,实际的 Photo 数据访问实现。
import domain.Photo; // 导入 Photo 类,表示照片信息的实体类。
import service.PhotoService; // 导入 PhotoService 接口,定义照片服务层的业务逻辑。
/**
* PhotoServiceImpl PhotoService
* PhotoDao
*/
public class PhotoServiceImpl implements PhotoService {
private PhotoDao dao = new PhotoDaoImpl();
private PhotoDao dao = new PhotoDaoImpl(); // 实例化 PhotoDaoImpl 对象,用于操作照片数据。
/**
*
*
* @param photo
*/
@Override
public void addPhoto(Photo photo) {
dao.addPhoto(photo);
dao.addPhoto(photo); // 调用 DAO 层方法将照片信息添加到数据库。
}
/**
* ID
*
* @param id ID
* @return ID
*/
@Override
public Photo findPhotoByPhotoId(String id) {
return dao.findPhotoByPhotoId(id);
return dao.findPhotoByPhotoId(id); // 调用 DAO 层方法查询指定 ID 的照片。
}
/**
*
*
* @param photo
*/
@Override
public void updatePhoto(Photo photo) {
dao.updatePhoto(photo);
dao.updatePhoto(photo); // 调用 DAO 层方法更新照片信息。
}
}

@ -1,27 +1,52 @@
package service.impl;
import dao.SelectCourseDao;
import dao.impl.SelectCourseDaoImpl;
import domain.SelectCourse;
import service.SelectCourseService;
import dao.SelectCourseDao; // 导入 SelectCourseDao 接口,操作选课数据。
import dao.impl.SelectCourseDaoImpl; // 导入 SelectCourseDaoImpl 类,实际的选课数据访问实现。
import domain.SelectCourse; // 导入 SelectCourse 类,表示选课信息的实体类。
import service.SelectCourseService; // 导入 SelectCourseService 接口,定义选课服务层的业务逻辑。
import java.util.List;
/**
* SelectCourseServiceImpl SelectCourseService
* SelectCourseDao
*/
public class SelectCourseServiceImpl implements SelectCourseService {
private SelectCourseDao dao = new SelectCourseDaoImpl();
private SelectCourseDao dao = new SelectCourseDaoImpl(); // 实例化 SelectCourseDaoImpl 对象,用于操作选课数据。
/**
* ID
*
* @param cid ID
* @return
*/
@Override
public List<SelectCourse> findStudentSelectedCourseByCourseId(String cid) {
return dao.findStudentSelectedCourseByCourseId(cid);
return dao.findStudentSelectedCourseByCourseId(cid); // 调用 DAO 层方法根据课程 ID 查找所有选课学生。
}
/**
* ID ID
*
* @param cid ID
* @param sid ID
* @return
*/
@Override
public SelectCourse findScoreByCourseIdAndStudentId(String cid, String sid) {
return dao.findScoreByCourseIdAndStudentId(cid,sid);
return dao.findScoreByCourseIdAndStudentId(cid, sid); // 调用 DAO 层方法查找指定课程和学生的成绩。
}
/**
*
*
* @param cid ID
* @param sid ID
* @param sScore
*/
@Override
public void upDateScoreByCidAndSid(String cid, String sid, String sScore) {
dao.upDateScoreByCidAndSid(cid,sid,sScore);
dao.upDateScoreByCidAndSid(cid, sid, sScore); // 调用 DAO 层方法更新指定学生和课程的成绩。
}
}

@ -1,114 +1,196 @@
package service.impl;
import dao.StudentDao;
import dao.impl.StudentDaoImpl;
import domain.Course;
import domain.PageBean;
import domain.SelectCourse;
import domain.Student;
import service.StudentService;
import dao.StudentDao; // 导入 StudentDao 接口,操作学生数据。
import dao.impl.StudentDaoImpl; // 导入 StudentDaoImpl 类,实际的学生数据访问实现。
import domain.Course; // 导入 Course 类,表示课程信息。
import domain.PageBean; // 导入 PageBean 类,表示分页对象。
import domain.SelectCourse; // 导入 SelectCourse 类,表示选课信息。
import domain.Student; // 导入 Student 类,表示学生信息。
import service.StudentService; // 导入 StudentService 接口,定义学生服务层的业务逻辑。
import java.util.List;
import java.util.Map;
/**
* StudentServiceImpl StudentService
* StudentDao
*/
public class StudentServiceImpl implements StudentService {
private StudentDao dao = new StudentDaoImpl();
private StudentDao dao = new StudentDaoImpl(); // 实例化 StudentDaoImpl 对象,用于操作学生数据。
/**
*
*
* @param _currentPage
* @param _rows
* @param condition Map
* @return PageBean
*/
@Override
public PageBean<Student> findStudentByPage(String _currentPage, String _rows, Map<String, String[]> condition) {
// 转换当前页和每页记录数
int currentPage = Integer.parseInt(_currentPage);
int rows = Integer.parseInt(_rows);
//创建新的PageBean对象
// 创建新的 PageBean 对象
PageBean<Student> pb = new PageBean<Student>();
//设置参数
// 设置分页参数
pb.setCurrentPage(currentPage);
pb.setRows(rows);
//调用dao查询总记录数
// 查询总记录数并设置到 PageBean
int totalCount = dao.findTotalCount(condition);
pb.setTotalCount(totalCount);
//调用dao查询List集合
//计算开始记录的索引
// 计算开始记录的索引
int start = (currentPage - 1) * rows;
List<Student>list = dao.findByPage(start,rows,condition);
List<Student> list = dao.findByPage(start, rows, condition); // 查询分页数据
pb.setList(list);
//计算总页码
int totalPage = (totalCount % rows) == 0 ? totalCount/rows : (totalCount/rows) + 1;
// 计算总页码
int totalPage = (totalCount % rows) == 0 ? totalCount / rows : (totalCount / rows) + 1;
pb.setTotalPage(totalPage);
return pb;
}
/**
*
*
* @return
*/
@Override
public List<Student> findAll() {
return dao.findAll();
return dao.findAll(); // 调用 DAO 层的 findAll 方法获取所有学生信息
}
/**
*
*
* @param student ID
* @return null
*/
@Override
public Student login(Student student) {
return dao.findStudentidAndPassword(student.getS_id(),student.getS_password());
return dao.findStudentidAndPassword(student.getS_id(), student.getS_password()); // 调用 DAO 层方法进行登录验证
}
/**
* ID
*
* @param student ID
* @return
*/
@Override
public Student findStudentById(Student student) {
return dao.findStudentById(student.getS_id());
return dao.findStudentById(student.getS_id()); // 调用 DAO 层方法根据学生 ID 查询学生信息
}
/**
*
*
* @param student
*/
@Override
public void register(Student student) {
dao.addStudent(student);
dao.addStudent(student); // 调用 DAO 层方法注册学生
}
/**
*
*
* @param student
*/
@Override
public void updateInfo(Student student) {
dao.updateInfo(student);
dao.updateInfo(student); // 调用 DAO 层方法更新学生信息
}
/**
*
*
* @param studentid ID
* @param newpassword
*/
@Override
public void updatePassword(String studentid, String newpassword) {
dao.updatePassword(studentid,newpassword);
dao.updatePassword(studentid, newpassword); // 调用 DAO 层方法更新学生密码
}
/**
* ID
*
* @param studentid ID
* @return
*/
@Override
public List<SelectCourse> findAllSelectCourse(String studentid) {
return dao.findAllSelectCourse(studentid);
return dao.findAllSelectCourse(studentid); // 调用 DAO 层方法获取该学生的选课信息
}
/**
*
*
* @return
*/
@Override
public List<Course> findAllOptionalCourse() {
return dao.findAllOptionalCourse();
return dao.findAllOptionalCourse(); // 调用 DAO 层方法获取所有可选课程信息
}
/**
*
*
* @param studentid ID
* @param courseid ID
*/
@Override
public void addSelectCourse(String studentid, String courseid) {
dao.addSelectCourse(studentid,courseid);
dao.addSelectCourse(studentid, courseid); // 调用 DAO 层方法进行选课
}
/**
*
*
* @param studentid ID
*/
@Override
public void deleteStudentById(String studentid) {
dao.deleteStudentById(studentid);
dao.deleteStudentById(studentid); // 调用 DAO 层方法删除指定学生
}
/**
*
*
* @param sids ID ID
*/
@Override
public void deleteSelectStudent(String[] sids) {
if (sids != null && sids.length > 0) {
for (String sid: sids) {
dao.deleteStudentById(sid);
for (String sid : sids) {
dao.deleteStudentById(sid); // 调用 DAO 层方法批量删除学生
}
}
}
/**
*
*
* @param updateStudent
*/
@Override
public void addStudentAllInfo(Student updateStudent) {
dao.addStudentAllInfo(updateStudent);
dao.addStudentAllInfo(updateStudent); // 调用 DAO 层方法添加学生的完整信息
}
/**
*
*
* @return
*/
@Override
public List<SelectCourse> findSelectCourseAllStudent() {
return dao.findSelectCourseAllStudent();
return dao.findSelectCourseAllStudent(); // 调用 DAO 层方法获取所有学生的选课信息
}
}

@ -1,68 +1,133 @@
package service.impl;
import dao.TeacherDao;
import domain.Course;
import domain.Teacher;
import dao.impl.TeacherDaoImpl;
import service.TeacherService;
import dao.TeacherDao; // 导入 TeacherDao 接口,处理教师数据访问。
import domain.Course; // 导入 Course 类,表示课程信息。
import domain.Teacher; // 导入 Teacher 类,表示教师信息。
import dao.impl.TeacherDaoImpl; // 导入 TeacherDaoImpl 类,实际的教师数据访问实现。
import service.TeacherService; // 导入 TeacherService 接口,定义教师服务层的业务逻辑。
import java.util.List;
/**
* TeacherServiceImpl TeacherService
* TeacherDao
*/
public class TeacherServiceImpl implements TeacherService {
private TeacherDao dao = new TeacherDaoImpl();
private TeacherDao dao = new TeacherDaoImpl(); // 实例化 TeacherDaoImpl 对象,用于操作教师数据。
/**
*
*
* @param teacher ID
* @return null
*/
@Override
public Teacher login(Teacher teacher) {
return dao.findTeacheridAndPassword(teacher.getT_id(),teacher.getT_password());
return dao.findTeacheridAndPassword(teacher.getT_id(), teacher.getT_password()); // 调用 DAO 层方法进行登录验证
}
/**
*
*
* @return
*/
@Override
public List<Teacher> findAll() {
return dao.findAll();
return dao.findAll(); // 调用 DAO 层的 findAll 方法获取所有教师信息
}
/**
*
*
* @param T_id ID
* @return
*/
@Override
public List<Course> findMySelfOptionalCourse(String T_id) {
return dao.findMySelfOptionalCourse(T_id);
return dao.findMySelfOptionalCourse(T_id); // 调用 DAO 层方法获取该教师的可选课程
}
/**
* ID
*
* @param cid ID
* @return
*/
@Override
public Course findOptionalCourseByCourseId(String cid) {
return dao.findOptionalCourseByCourseId(cid);
return dao.findOptionalCourseByCourseId(cid); // 调用 DAO 层方法根据课程 ID 查询课程信息
}
/**
*
*
* @param updateCourse
*/
@Override
public void updateCourseInfo(Course updateCourse) {
dao.updateCourseInfo(updateCourse);
dao.updateCourseInfo(updateCourse); // 调用 DAO 层方法更新课程信息
}
/**
*
*
* @param cid ID
*/
@Override
public void deleteCourseById(String cid) {
dao.deleteCourseById(cid);
dao.deleteCourseById(cid); // 调用 DAO 层方法删除指定课程
}
/**
*
*
* @param teacherid ID
* @param newpassword
*/
@Override
public void updatePassword(String teacherid, String newpassword) {
dao.updatePassword(teacherid,newpassword);
dao.updatePassword(teacherid, newpassword); // 调用 DAO 层方法更新教师密码
}
/**
* ID
*
* @param teacher ID
* @return
*/
@Override
public Teacher findTeacherById(Teacher teacher) {
return dao.findTeacherById(teacher.getT_id());
return dao.findTeacherById(teacher.getT_id()); // 调用 DAO 层方法根据教师 ID 查询教师信息
}
/**
*
*
* @param updateTeacher
*/
@Override
public void addTeacherAllInfo(Teacher updateTeacher) {
dao.addTeacherAllInfo(updateTeacher);
dao.addTeacherAllInfo(updateTeacher); // 调用 DAO 层方法添加教师的完整信息
}
/**
*
*
* @param teacherid ID
*/
@Override
public void deleteTeacherById(String teacherid) {
dao.deleteTeacherById(teacherid);
dao.deleteTeacherById(teacherid); // 调用 DAO 层方法删除指定教师
}
/**
*
*
* @param updateTeacher
*/
@Override
public void updateInfo(Teacher updateTeacher) {
dao.updateInfo(updateTeacher);
dao.updateInfo(updateTeacher); // 调用 DAO 层方法更新教师信息
}
}

@ -10,15 +10,7 @@ import java.sql.Statement;
import java.util.Properties;
/**
<<<<<<< HEAD
<<<<<<< HEAD
* Druid,dao
=======
* Druid,dao--
>>>>>>> remotes/origin/develop
=======
* Druid,dao--
>>>>>>> remotes/origin/develop
*/
public class JDBCUtils {
private static DataSource dataSource; //定义成员变量DataSource

@ -15,218 +15,57 @@ import java.util.Date;
@WebServlet("/addStudentInfoServlet")
public class AddStudentInfoServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//设置请求编码
request.setCharacterEncoding("utf-8");
//创建学生服务对象
StudentService service= new StudentServiceImpl();
//先进行判断是否已存在该学生
String sid = request.getParameter("student-id");
// 创建一个Student对象
Student s = new Student();
// 设置学生ID
s.setS_id(sid);
// 根据学生ID查找学生
Student newStudent = service.findStudentById(s);
// 如果找到了该学生
if (newStudent != null) {
// 设置更新消息
request.setAttribute("update_msg","已存在该学生,请重新添加!"+String.format("%tT",new Date()));
// 转发到addStudentServlet
request.getRequestDispatcher("addStudentServlet").forward(request, response);
}else {
// 获取学生姓名
String name = request.getParameter("student-name");
// 获取学生性别
String sex = request.getParameter("student-sex");
// 获取学生年龄
String age = request.getParameter("student-age");
// 获取学生电话
String phone = request.getParameter("student-phone");
// 获取学生邮箱
String email = request.getParameter("student-email");
// 获取学生地址
String address = request.getParameter("student-address");
// 获取学生所在学院
String college = request.getParameter("selectCollege");
// 获取学生所在系
String department = request.getParameter("selectDepartment");
// 获取学生所在班级
// 获取请求参数selectClass的值
String cclass = request.getParameter("selectClass");
// 如果college参数为空则将其赋值为"待分配"
if ("".equals(college)) {
college = "待分配";
}
// 如果department参数为空则将其赋值为"待分配"
if ("".equals(department)) {
department = "待分配";
}
// 如果cclass参数为空则将其赋值为"待分配"
// 如果cclass为空则将其设置为"待分配"
if ("".equals(cclass)) {
cclass = "待分配";
}
// 创建一个Student对象
Student updateStudent = new Student();
// 设置Student对象的属性
// 设置学生ID
updateStudent.setS_id(sid);
// 设置学生姓名
updateStudent.setS_name(name);
// 设置学生性别
updateStudent.setS_sex(sex);
// 设置学生年龄
updateStudent.setS_age(age);
// 设置学生电话
updateStudent.setS_phone(phone);
// 设置学生邮箱
updateStudent.setS_email(email);
// 设置学生地址
updateStudent.setS_address(address);
// 设置学生学院
updateStudent.setS_college(college);
// 设置学生系别
updateStudent.setS_department(department);
// 设置学生班级
updateStudent.setS_class(cclass);
//protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//调用service层的方法添加学生信息
service.addStudentAllInfo(updateStudent);
<<<<<<< HEAD
<<<<<<< HEAD
request.setAttribute("update_msg","添加成功!"+String.format("%tT",new Date()));
=======
//将添加信息返回给客户端
request.setAttribute("update_msg","添加成功!"+String.format("%tT",new Date()));//返回添加信息
//将请求转发到addStudentServlet
>>>>>>> remotes/origin/develop
=======
//将添加信息返回给客户端
request.setAttribute("update_msg","添加成功!"+String.format("%tT",new Date()));//返回添加信息
//将请求转发到addStudentServlet
>>>>>>> remotes/origin/develop
request.getRequestDispatcher("addStudentServlet").forward(request, response);
}
}
//处理get请求
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//调用doPost方法
doPost(request,response);
}
}
//package web.servlet.admin;
//
//import domain.Student;
//import service.StudentService;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.Date;
//
//@WebServlet("/addStudentInfoServlet")
//public class AddStudentInfoServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// //设置请求编码
// request.setCharacterEncoding("utf-8");
// //创建学生服务对象
// StudentService service= new StudentServiceImpl();
// //先进行判断是否已存在该学生-
// String sid = request.getParameter("student-id");
// // 创建一个Student对象
// Student s = new Student();
// // 设置学生ID
// s.setS_id(sid);
// // 根据学生ID查找学生
// Student newStudent = service.findStudentById(s);
// // 如果找到了该学生
// if (newStudent != null) {
// // 设置更新消息
// request.setAttribute("update_msg","已存在该学生,请重新添加!"+String.format("%tT",new Date()));
// // 转发到addStudentServlet
// request.getRequestDispatcher("addStudentServlet").forward(request, response);
// }else {
// // 获取学生姓名
// String name = request.getParameter("student-name");
// // 获取学生性别
// String sex = request.getParameter("student-sex");
// // 获取学生年龄
// String age = request.getParameter("student-age");
// // 获取学生电话
// String phone = request.getParameter("student-phone");
// // 获取学生邮箱
// String email = request.getParameter("student-email");
// // 获取学生地址
// String address = request.getParameter("student-address");
// // 获取学生所在学院
// String college = request.getParameter("selectCollege");
// // 获取学生所在系
// String department = request.getParameter("selectDepartment");
// // 获取学生所在班级
// // 获取请求参数selectClass的值
// String cclass = request.getParameter("selectClass");
// // 如果college参数为空则将其赋值为"待分配"
// if ("".equals(college)) {
// college = "待分配";
// }
// // 如果department参数为空则将其赋值为"待分配"
// if ("".equals(department)) {
// department = "待分配";
// }
// // 如果cclass参数为空则将其赋值为"待分配"
// // 如果cclass为空则将其设置为"待分配"
// if ("".equals(cclass)) {
// cclass = "待分配";
// }
//
// // 创建一个Student对象
// Student updateStudent = new Student();
//
// // 设置Student对象的属性
// // 设置学生ID
// updateStudent.setS_id(sid);
// // 设置学生姓名
// updateStudent.setS_name(name);
// // 设置学生性别
// updateStudent.setS_sex(sex);
// // 设置学生年龄
// updateStudent.setS_age(age);
// // 设置学生电话
// updateStudent.setS_phone(phone);
// // 设置学生邮箱
// updateStudent.setS_email(email);
// // 设置学生地址
// updateStudent.setS_address(address);
// // 设置学生学院
// updateStudent.setS_college(college);
// // 设置学生系别
// updateStudent.setS_department(department);
// // 设置学生班级
// updateStudent.setS_class(cclass);
//
////protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// //调用service层的方法添加学生信息
// service.addStudentAllInfo(updateStudent);
// //将添加信息返回给客户端
// request.setAttribute("update_msg","添加成功!"+String.format("%tT",new Date()));//返回添加信息
// //将请求转发到addStudentServlet
// request.getRequestDispatcher("addStudentServlet").forward(request, response);
//
// }
// }
//
// //处理get请求
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// //调用doPost方法
// doPost(request,response);
// }
//}

@ -22,29 +22,15 @@ public class AddStudentServlet extends HttpServlet {
request.setCharacterEncoding("utf-8");
HttpSession session = request.getSession();
<<<<<<< HEAD
=======
// 创建CDCService的实例通常用于处理与学院、系、班级相关的业务逻辑
// 创建CDCService的实现类
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
CDCService service2 = new CDCServiceImpl();
// 调用findAllCollege方法获取所有学院列表
List<CDC> collegeList = service2.findAllCollege();
// 调用findAllDepartment方法获取所有部门列表
List<CDC> departmentList = service2.findAllDepartment();
// 调用findAllClass方法获取所有班级列表
// 获取所有班级信息
List<CDC> classList = service2.findAllClass();
// 将学院列表、系列表、班级列表存入session中
session.setAttribute("collegeLists",collegeList);
session.setAttribute("departmentLists",departmentList);
session.setAttribute("classLists",classList);
// 转发到添加学生页面
request.getRequestDispatcher("/WEB-INF/admin/addStudent.jsp").forward(request,response);
}
@ -52,55 +38,3 @@ public class AddStudentServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.admin;
//
//import domain.CDC;
//import domain.Student;
//import service.CDCService;
//import service.StudentService;
//import service.impl.CDCServiceImpl;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//import java.util.List;
//
///**
// * 添加学生的Servlet处理类
// */
//@WebServlet("/addStudentServlet")
//public class AddStudentServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求编码为UTF-8以支持中文字符的正确处理
// request.setCharacterEncoding("utf-8");
// HttpSession session = request.getSession();
//
// // 创建CDCService的实例通常用于处理与学院、系、班级相关的业务逻辑
// // 创建CDCService的实现类
// CDCService service2 = new CDCServiceImpl();
// // 调用findAllCollege方法获取所有学院列表
// List<CDC> collegeList = service2.findAllCollege();
// // 调用findAllDepartment方法获取所有部门列表
// List<CDC> departmentList = service2.findAllDepartment();
// // 调用findAllClass方法获取所有班级列表
// // 获取所有班级信息
// List<CDC> classList = service2.findAllClass();
//
// // 将学院列表、系列表、班级列表存入session中
// session.setAttribute("collegeLists",collegeList);
// session.setAttribute("departmentLists",departmentList);
// session.setAttribute("classLists",classList);
//
// // 转发到添加学生页面
// request.getRequestDispatcher("/WEB-INF/admin/addStudent.jsp").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -17,26 +17,3 @@ public class AdminPasswordIndexServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.admin;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//@WebServlet("/adminPasswordIndexServlet")
///*
// 管理员密码更新界面的Servlet处理类
// */
//public class AdminPasswordIndexServlet extends HttpServlet {
// // 将请求转发到管理员密码更新界面
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.getRequestDispatcher("/WEB-INF/admin/adminUpdatePassword.jsp").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -18,51 +18,32 @@ import java.util.Date;
@WebServlet("/adminPasswordUpdateServlet")
public class AdminPasswordUpdateServlet extends HttpServlet {
// 处理POST请求
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求编码为utf-8
request.setCharacterEncoding("utf-8");
// 获取当前会话
HttpSession session = request.getSession();
// 从会话中获取管理员对象
Admin admin= (Admin) session.getAttribute("admin");
// 获取管理员ID
String adminid = admin.getA_id();
// 获取新密码
String newpassword = request.getParameter("admin-newpassword");
// 获取确认新密码
String ennewpassword = request.getParameter("admin-ennewpassword");
// 定义正则表达式,用于验证密码格式
String regex = "^[\\w]{3,12}$";
// 判断新密码是否符合正则表达式
boolean flag = newpassword.matches(regex);
// 如果不符合,则设置错误信息,并跳转到更新密码页面
if (!flag) {
request.setAttribute("update_msg", "密码格式错误,重新提交!"+String.format("%tT",new Date()));
request.getRequestDispatcher("/WEB-INF/admin/adminUpdatePassword.jsp").forward(request, response);
// 如果新密码和确认密码不一致,则设置错误信息,并跳转到更新密码页面
} else if (!newpassword.equals(ennewpassword)) {
request.setAttribute("update_msg", "密码确认错误,请重新提交!" + String.format("%tT", new Date()));
request.getRequestDispatcher("/WEB-INF/admin/adminUpdatePassword.jsp").forward(request, response);
// 如果新密码和确认密码一致,则继续执行
} else {
// 创建AdminService实例
AdminService service= new AdminServiceImpl();
// 调用updatePassword方法更新密码
service.updatePassword(adminid,newpassword);
// 调用findAdminById方法根据adminid查找管理员信息
Admin newAdmin = service.findAdminById(admin);
// 将新的管理员信息赋值给admin
admin = newAdmin;
// 将新的管理员信息存入session中
session.setAttribute("admin",admin);
// 设置更新成功的信息
request.setAttribute("update_msg", "修改成功!" + String.format("%tT", new Date()));
// 转发到adminUpdatePassword.jsp页面
request.getRequestDispatcher("/WEB-INF/admin/adminUpdatePassword.jsp").forward(request, response);
}
@ -72,79 +53,3 @@ public class AdminPasswordUpdateServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.admin;
//
//import domain.Admin;
//import domain.Student;
//import service.AdminService;
//import service.StudentService;
//import service.impl.AdminServiceImpl;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//import java.util.Date;
///**
// * 管理员密码更新的Servlet处理类
// */
//@WebServlet("/adminPasswordUpdateServlet")
//public class AdminPasswordUpdateServlet extends HttpServlet {
// // 处理POST请求
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求编码为utf-8
// request.setCharacterEncoding("utf-8");
// // 获取当前会话
// HttpSession session = request.getSession();
// // 从会话中获取管理员对象
// Admin admin= (Admin) session.getAttribute("admin");
//
// // 获取管理员ID
// String adminid = admin.getA_id();
// // 获取新密码
// String newpassword = request.getParameter("admin-newpassword");
// // 获取确认新密码
// String ennewpassword = request.getParameter("admin-ennewpassword");
// // 定义正则表达式,用于验证密码格式
// String regex = "^[\\w]{3,12}$";
// // 判断新密码是否符合正则表达式
// boolean flag = newpassword.matches(regex);
// // 如果不符合,则设置错误信息,并跳转到更新密码页面
// if (!flag) {
// request.setAttribute("update_msg", "密码格式错误,重新提交!"+String.format("%tT",new Date()));
// request.getRequestDispatcher("/WEB-INF/admin/adminUpdatePassword.jsp").forward(request, response);
// // 如果新密码和确认密码不一致,则设置错误信息,并跳转到更新密码页面
// } else if (!newpassword.equals(ennewpassword)) {
// request.setAttribute("update_msg", "密码确认错误,请重新提交!" + String.format("%tT", new Date()));
// request.getRequestDispatcher("/WEB-INF/admin/adminUpdatePassword.jsp").forward(request, response);
// // 如果新密码和确认密码一致,则继续执行
// } else {
//
// // 创建AdminService实例
// AdminService service= new AdminServiceImpl();
// // 调用updatePassword方法更新密码
// service.updatePassword(adminid,newpassword);
//
// // 调用findAdminById方法根据adminid查找管理员信息
// Admin newAdmin = service.findAdminById(admin);
// // 将新的管理员信息赋值给admin
// admin = newAdmin;
// // 将新的管理员信息存入session中
// session.setAttribute("admin",admin);
//
// // 设置更新成功的信息
// request.setAttribute("update_msg", "修改成功!" + String.format("%tT", new Date()));
// // 转发到adminUpdatePassword.jsp页面
// request.getRequestDispatcher("/WEB-INF/admin/adminUpdatePassword.jsp").forward(request, response);
// }
//
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -16,32 +16,12 @@ import java.io.IOException;
@WebServlet("/doDeleteSelectCourseServlet")
public class DoDeleteSelectCourseServlet extends HttpServlet {
<<<<<<< HEAD
=======
/**
* POST
*
* @param request HTTP
* @param response HTTP
* @throws IOException
*/
// 处理POST请求
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求编码为utf-8
request.setCharacterEncoding("utf-8");
// 获取当前会话
HttpSession session = request.getSession();
// 获取请求参数cid
String cid = request.getParameter("cid");
// 创建CourseService实例
CourseService service = new CourseServiceImpl();
// 根据cid删除课程
service.deleteServiceById(cid);
// 转发到studentOptionalCourseServlet
request.getRequestDispatcher("/studentOptionalCourseServlet").forward(request,response);
}
@ -49,50 +29,3 @@ public class DoDeleteSelectCourseServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.admin;
//
//import domain.Course;
//import service.CourseService;
//import service.StudentService;
//import service.impl.CourseServiceImpl;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
///**
// * 处理学生选课删除请求的Servlet
// */
//@WebServlet("/doDeleteSelectCourseServlet")
//public class DoDeleteSelectCourseServlet extends HttpServlet {
// /**
// * 处理POST请求执行选课删除操作。
// *
// * @param request HTTP请求对象包含客户端发送的数据。
// * @param response HTTP响应对象用于生成返回给客户端的响应。
// * @throws IOException 如果输入或输出异常发生。
// */
// // 处理POST请求
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求编码为utf-8
// request.setCharacterEncoding("utf-8");
// // 获取当前会话
// HttpSession session = request.getSession();
// // 获取请求参数cid
// String cid = request.getParameter("cid");
// // 创建CourseService实例
// CourseService service = new CourseServiceImpl();
// // 根据cid删除课程
// service.deleteServiceById(cid);
// // 转发到studentOptionalCourseServlet
// request.getRequestDispatcher("/studentOptionalCourseServlet").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -31,29 +31,19 @@ public class UpdateStudentInfoServlet extends HttpServlet {
//保存输入内容
// 获取请求参数中的学生姓名
String name = request.getParameter("student-name");
// 输出学生姓名
System.out.println("sname:"+name);
// 获取请求参数中的学生性别
String sex = request.getParameter("student-sex");
// 输出学生性别
System.out.println("ssex:"+sex);
// 获取请求参数中的学生年龄
String age = request.getParameter("student-age");
// 获取请求参数中的学生电话
String phone = request.getParameter("student-phone");
// 获取请求参数中的学生邮箱
String email = request.getParameter("student-email");
// 获取请求参数中的学生地址
String address = request.getParameter("student-address");
// 获取请求参数
String college = request.getParameter("selectCollege");
String department = request.getParameter("selectDepartment");
String cclass = request.getParameter("selectClass");
// 创建一个学生对象
Student updateStudent = new Student();
//判断输入位数是否大于数据库位数
@ -61,33 +51,16 @@ public class UpdateStudentInfoServlet extends HttpServlet {
request.setAttribute("update_msg","格式错误,请重新提交!"+String.format("%tT",new Date()));
request.getRequestDispatcher("updateStudentServlet?sid="+sid).forward(request, response);
}else {
<<<<<<< HEAD
//封装学生对象
=======
//封装学生对象-
// 设置学生ID
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
updateStudent.setS_id(sid);
// 设置学生姓名
updateStudent.setS_name(name);
// 设置学生性别
updateStudent.setS_sex(sex);
// 设置学生年龄
updateStudent.setS_age(age);
// 设置学生电话
updateStudent.setS_phone(phone);
// 设置学生邮箱
updateStudent.setS_email(email);
// 设置学生地址
updateStudent.setS_address(address);
// 设置学生学院
updateStudent.setS_college(college);
// 设置学生系别
updateStudent.setS_department(department);
// 设置学生班级
updateStudent.setS_class(cclass);
//调用studentUpdata服务
@ -104,102 +77,3 @@ public class UpdateStudentInfoServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.admin;
//
//
//
//import domain.CDC;
//import domain.Student;
//import service.CDCService;
//import service.StudentService;
//import service.impl.CDCServiceImpl;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//import java.text.SimpleDateFormat;
//import java.util.Date;
//import java.util.List;
//
//@WebServlet("/updateStudentInfoServlet")
//public class UpdateStudentInfoServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//
// request.setCharacterEncoding("utf-8");
//// HttpSession session = request.getSession();
// String sid = request.getParameter("student-id");
// System.out.println("sid:"+sid);
//
//
// //保存输入内容
// // 获取请求参数中的学生姓名
// String name = request.getParameter("student-name");
// // 输出学生姓名
// System.out.println("sname:"+name);
// // 获取请求参数中的学生性别
// String sex = request.getParameter("student-sex");
// // 输出学生性别
// System.out.println("ssex:"+sex);
// // 获取请求参数中的学生年龄
// String age = request.getParameter("student-age");
// // 获取请求参数中的学生电话
// String phone = request.getParameter("student-phone");
// // 获取请求参数中的学生邮箱
// String email = request.getParameter("student-email");
// // 获取请求参数中的学生地址
// String address = request.getParameter("student-address");
//
// // 获取请求参数
// String college = request.getParameter("selectCollege");
// String department = request.getParameter("selectDepartment");
// String cclass = request.getParameter("selectClass");
//
// // 创建一个学生对象
// Student updateStudent = new Student();
//
// //判断输入位数是否大于数据库位数-
// if (name.length() > 4 || phone.length() > 11 || email.length()>24 || address.length() > 24 || age.length()>2 || name.contains("<") || phone.contains("<") || email.contains("<") || address.contains("<") || age.contains("<")) {
// request.setAttribute("update_msg","格式错误,请重新提交!"+String.format("%tT",new Date()));
// request.getRequestDispatcher("updateStudentServlet?sid="+sid).forward(request, response);
// }else {
// //封装学生对象-
// // 设置学生ID
// updateStudent.setS_id(sid);
// // 设置学生姓名
// updateStudent.setS_name(name);
// // 设置学生性别
// updateStudent.setS_sex(sex);
// // 设置学生年龄
// updateStudent.setS_age(age);
// // 设置学生电话
// updateStudent.setS_phone(phone);
// // 设置学生邮箱
// updateStudent.setS_email(email);
// // 设置学生地址
// updateStudent.setS_address(address);
// // 设置学生学院
// updateStudent.setS_college(college);
// // 设置学生系别
// updateStudent.setS_department(department);
// // 设置学生班级
// updateStudent.setS_class(cclass);
//
// //调用studentUpdata服务-
// StudentService service= new StudentServiceImpl();
// service.updateInfo(updateStudent);
//
// //成功则返回并给提示
// request.setAttribute("update_msg", "修改成功!"+String.format("%tT",new Date()));
// request.getRequestDispatcher("updateStudentServlet?sid="+sid).forward(request, response);
// }
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -30,27 +30,13 @@ public class UpdateStudentServlet extends HttpServlet {
Student newStudent = service.findStudentById(student);
request.setAttribute("student",newStudent);
<<<<<<< HEAD
=======
// 创建 CDCService 的实现类实例,用于处理与院系、系别和班级相关的业务逻辑
// 创建CDCService实例
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
CDCService service2 = new CDCServiceImpl();
// 调用findAllCollege方法获取所有学院列表
List<CDC> collegeList = service2.findAllCollege();
// 调用findAllDepartment方法获取所有部门列表
List<CDC> departmentList = service2.findAllDepartment();
// 调用findAllClass方法获取所有班级列表
List<CDC> classList = service2.findAllClass();
// 将学院列表存入session中
session.setAttribute("collegeLists",collegeList);
// 将部门列表存入session中
session.setAttribute("departmentLists",departmentList);
// 将班级列表存入session中
session.setAttribute("classLists",classList);
request.getRequestDispatcher("/WEB-INF/admin/updateStudent.jsp").forward(request,response);
@ -60,60 +46,3 @@ public class UpdateStudentServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.admin;
//
//import domain.CDC;
//import domain.Student;
//import service.CDCService;
//import service.StudentService;
//import service.impl.CDCServiceImpl;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//import java.util.List;
//
//@WebServlet("/updateStudentServlet")
//public class UpdateStudentServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.setCharacterEncoding("utf-8");
// HttpSession session = request.getSession();
// String studentid = request.getParameter("sid");
//// session.setAttribute("sid",studentid);
//
// Student student = new Student();
// student.setS_id(studentid);
// // 创建学生服务的实现类实例,用于处理与学生相关的业务逻辑
// StudentService service = new StudentServiceImpl();
// Student newStudent = service.findStudentById(student);
// request.setAttribute("student",newStudent);
//
// // 创建 CDCService 的实现类实例,用于处理与院系、系别和班级相关的业务逻辑
// // 创建CDCService实例
// CDCService service2 = new CDCServiceImpl();
// // 调用findAllCollege方法获取所有学院列表
// List<CDC> collegeList = service2.findAllCollege();
// // 调用findAllDepartment方法获取所有部门列表
// List<CDC> departmentList = service2.findAllDepartment();
// // 调用findAllClass方法获取所有班级列表
// List<CDC> classList = service2.findAllClass();
//
// // 将学院列表存入session中
// session.setAttribute("collegeLists",collegeList);
// // 将部门列表存入session中
// session.setAttribute("departmentLists",departmentList);
// // 将班级列表存入session中
// session.setAttribute("classLists",classList);
//
// request.getRequestDispatcher("/WEB-INF/admin/updateStudent.jsp").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -28,25 +28,17 @@ public class CDCListServlet extends HttpServlet {
//将list存入request域
request.setAttribute("cdcs",cdcs);
// 获取当前会话
HttpSession session = request.getSession();
// 从会话中获取学生对象
Student student= (Student)session.getAttribute("student");
// 从会话中获取管理员对象
Admin admin= (Admin)session.getAttribute("admin");
// 从会话中获取教师对象
Teacher teacher= (Teacher)session.getAttribute("teacher");
// 如果会话中存在学生对象且不存在管理员对象和教师对象则跳转到学生CDC列表页面
if (student != null && admin == null && teacher == null) {
request.getRequestDispatcher("/WEB-INF/student/sCDCList.jsp").forward(request, response);
// 如果会话中存在管理员对象且不存在学生对象和教师对象则跳转到管理员CDC列表页面
} else if (admin != null && student == null && teacher == null) {
request.getRequestDispatcher("/WEB-INF/admin/aCDCList.jsp").forward(request, response);
// 如果会话中存在教师对象且不存在学生对象和管理员对象则跳转到教师CDC列表页面
} else if (teacher != null && admin == null && student == null) {
request.getRequestDispatcher("/WEB-INF/teacher/tCDCList.jsp").forward(request, response);
// 如果会话中不存在学生对象、管理员对象和教师对象,则跳转到错误页面
} else {
request.getRequestDispatcher("error.jsp").forward(request, response);
}
@ -56,61 +48,3 @@ public class CDCListServlet extends HttpServlet {
this.doPost(request,response);
}
}
//package web.servlet.cdc;
//
//import domain.Admin;
//import domain.CDC;
//import domain.Student;
//import domain.Teacher;
//import service.CDCService;
//import service.StudentService;
//import service.impl.CDCServiceImpl;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//import java.util.List;
//
//@WebServlet("/cdcListServlet")
//public class CDCListServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.setCharacterEncoding("utf-8");
// //调用StudentService完成查询-
// CDCService service = new CDCServiceImpl();
// List<CDC> cdcs = service.findAll();
// //将list存入request域-
// request.setAttribute("cdcs",cdcs);
//
// // 获取当前会话
// HttpSession session = request.getSession();
// // 从会话中获取学生对象
// Student student= (Student)session.getAttribute("student");
// // 从会话中获取管理员对象
// Admin admin= (Admin)session.getAttribute("admin");
// // 从会话中获取教师对象
// Teacher teacher= (Teacher)session.getAttribute("teacher");
//
// // 如果会话中存在学生对象且不存在管理员对象和教师对象则跳转到学生CDC列表页面
// if (student != null && admin == null && teacher == null) {
// request.getRequestDispatcher("/WEB-INF/student/sCDCList.jsp").forward(request, response);
// // 如果会话中存在管理员对象且不存在学生对象和教师对象则跳转到管理员CDC列表页面
// } else if (admin != null && student == null && teacher == null) {
// request.getRequestDispatcher("/WEB-INF/admin/aCDCList.jsp").forward(request, response);
// // 如果会话中存在教师对象且不存在学生对象和管理员对象则跳转到教师CDC列表页面
// } else if (teacher != null && admin == null && student == null) {
// request.getRequestDispatcher("/WEB-INF/teacher/tCDCList.jsp").forward(request, response);
// // 如果会话中不存在学生对象、管理员对象和教师对象,则跳转到错误页面
// } else {
// request.getRequestDispatcher("error.jsp").forward(request, response);
// }
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// this.doPost(request,response);
// }
//}

@ -29,19 +29,12 @@ public class AddComplaintsServlet extends HttpServlet {
text = text.replace("/script","");
}
// 判断文本是否为空
if (!text.equals("")) {
// 设置投诉内容
complaint.setContent(text);
// 获取当前时间
Date d = new Date();
// 设置时间格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 设置投诉日期
complaint.setCdate(sdf.format(d));
// 创建投诉服务对象
ComplaintService service = new ComplaintServiceImpl();
// 添加投诉
service.addComplaint(complaint);
}
@ -53,58 +46,3 @@ public class AddComplaintsServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.complaints;
//
//import domain.Complaint;
//import service.ComplaintService;
//import service.NotifyService;
//import service.impl.ComplaintServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.text.SimpleDateFormat;
//import java.util.Date;
//
//@WebServlet("/addComplaintsServlet")
//public class AddComplaintsServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.setCharacterEncoding("utf-8");
//
// //获取参数-
// Complaint complaint = new Complaint();
//
// String text = (String) request.getParameter("complaint");
//
// if (text.contains("script") && text.contains("/script")) {
// text = text.replace("script","");
// text = text.replace("/script","");
// }
//
// // 判断文本是否为空
// if (!text.equals("")) {
// // 设置投诉内容
// complaint.setContent(text);
// // 获取当前时间
// Date d = new Date();
// // 设置时间格式
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// // 设置投诉日期
// complaint.setCdate(sdf.format(d));
// // 创建投诉服务对象
// ComplaintService service = new ComplaintServiceImpl();
// // 添加投诉
// service.addComplaint(complaint);
// }
//
// response.sendRedirect("complaintServlet");
//// request.getRequestDispatcher("/complaintListServlet").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -14,54 +14,14 @@ import java.util.List;
@WebServlet("/complaintListServlet")
public class ComplaintListServlet extends HttpServlet {
// 处理 POST 请求
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求编码为 utf-8
request.setCharacterEncoding("utf-8");
// 创建投诉服务对象
ComplaintService service = new ComplaintServiceImpl();
// 查询所有投诉信息
List<Complaint> complaints = service.findAll();
request.setAttribute("complaints",complaints);
// 转发请求到 JSP 页面
request.getRequestDispatcher("/WEB-INF/complaint/complaintsList.jsp").forward(request,response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}
}
//package web.servlet.complaints;
//
//import domain.Complaint;
//import service.ComplaintService;
//import service.impl.ComplaintServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.List;
///**
// * 投诉列表处理的Servlet
// */
//@WebServlet("/complaintListServlet")
//public class ComplaintListServlet extends HttpServlet {
// // 处理 POST 请求
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求编码为 utf-8
// request.setCharacterEncoding("utf-8");
// // 创建投诉服务对象
// ComplaintService service = new ComplaintServiceImpl();
// // 查询所有投诉信息
// List<Complaint> complaints = service.findAll();
// // 将查询到的投诉信息存入请求属性,以便在后续的 JSP 页面中使用
// request.setAttribute("complaints",complaints);
// // 转发请求到 JSP 页面
// request.getRequestDispatcher("/WEB-INF/complaint/complaintsList.jsp").forward(request,response);
// }
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -15,22 +15,10 @@ import java.util.List;
@WebServlet("/complaintServlet")
public class ComplaintServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
<<<<<<< HEAD
=======
// 设置请求编码为UTF-8以支持中文字符的正确处理
// 设置请求的字符编码为utf-8
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
request.setCharacterEncoding("utf-8");
// 创建ComplaintService实例
ComplaintService service = new ComplaintServiceImpl();
// 调用findAll方法获取所有投诉信息
List<Complaint> complaints = service.findAll();
// 将投诉信息存入request对象中
request.setAttribute("complaints",complaints);
// 将请求转发到complaintsList.jsp页面
request.getRequestDispatcher("/WEB-INF/complaint/complaintsList.jsp").forward(request,response);
}
@ -38,46 +26,3 @@ public class ComplaintServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.complaints;
//
//import domain.Complaint;
//import service.ComplaintService;
//import service.impl.ComplaintServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.List;
///**
// * 投诉处理的Servlet
// */
//@WebServlet("/complaintServlet")
//public class ComplaintServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求编码为UTF-8以支持中文字符的正确处理
// // 设置请求的字符编码为utf-8
// request.setCharacterEncoding("utf-8");
// // 创建ComplaintService实例
// ComplaintService service = new ComplaintServiceImpl();
// // 调用findAll方法获取所有投诉信息
// List<Complaint> complaints = service.findAll();
// // 将投诉信息存入request对象中
// request.setAttribute("complaints",complaints);
// // 将请求转发到complaintsList.jsp页面
// request.getRequestDispatcher("/WEB-INF/complaint/complaintsList.jsp").forward(request,response);
// }
// /**
// * 处理GET请求调用POST请求处理方法。
// *
// * @param request HTTP请求对象包含客户端发送的数据。
// * @param response HTTP响应对象用于生成返回给客户端的响应。
// * @throws IOException 如果输入或输出异常发生。
// */
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -10,30 +10,10 @@ import java.io.IOException;
@WebServlet("/deleteFileServlet")
public class DeleteFileServlet extends HttpServlet {
<<<<<<< HEAD
=======
/**
* POST
*
* @param request HTTP
* @param response HTTP
* @throws ServletException
* @throws IOException
*/
// 处理POST请求
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求编码为utf-8
request.setCharacterEncoding("utf-8");
// 获取请求参数filename
String fileName = request.getParameter("filename");
// 获取上传文件的路径
File file = new File(this.getServletContext().getRealPath("upload")+File.separator+fileName);
// 如果文件存在,则删除
if (file.exists()) {
file.delete();
}
@ -44,45 +24,3 @@ public class DeleteFileServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.file;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.File;
//import java.io.IOException;
///**
// * 删除文件的Servlet
// */
//@WebServlet("/deleteFileServlet")
//public class DeleteFileServlet extends HttpServlet {
//
// /**
// * 处理POST请求执行文件删除操作。
// *
// * @param request HTTP请求对象包含客户端发送的数据。
// * @param response HTTP响应对象用于生成返回给客户端的响应。
// * @throws ServletException 如果处理请求时发生错误。
// * @throws IOException 如果输入或输出异常发生。
// */
// // 处理POST请求
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求编码为utf-8
// request.setCharacterEncoding("utf-8");
// // 获取请求参数filename
// String fileName = request.getParameter("filename");
// // 获取上传文件的路径
// File file = new File(this.getServletContext().getRealPath("upload")+File.separator+fileName);
// // 如果文件存在,则删除
// if (file.exists()) {
// file.delete();
// }
// request.getRequestDispatcher("/fileListServlet").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -17,41 +17,18 @@ import java.net.URLEncoder;
@WebServlet("/downloadServlet")
public class DownloadServlet extends HttpServlet {
<<<<<<< HEAD
=======
/**
* POST
*
* @param request HTTP
* @param response HTTP
* @throws ServletException
* @throws IOException
*/
// 处理POST请求
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 获取请求参数filename
String filename = request.getParameter("filename");
// 判断filename是否为../或/
if (filename.equalsIgnoreCase("../") || filename.equalsIgnoreCase("/")) {
// 如果是则转发到error.jsp页面
request.getRequestDispatcher("error.jsp").forward(request, response);
}
// 设置响应头content-Type为application/octet-stream
response.addHeader("content-Type", "application/octet-stream");
// 获取请求头User-Agent
String agent = request.getHeader("User-Agent");
// 判断User-Agent是否包含chrome
if (agent.toLowerCase().indexOf("chrome") > 0) {
// 如果包含则设置响应头content-Disposition为attachment;filename并将filename进行UTF-8和ISO8859-1编码
response.addHeader("content-Disposition", "attachment;filename=" + new String(filename.getBytes("UTF-8"), "ISO8859-1"));
} else {
// 如果不包含则设置响应头content-Disposition为attachment;filename并将filename进行UTF-8编码
response.addHeader("content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
}
InputStream in = getServletContext().getResourceAsStream("/upload/" + filename);
@ -64,24 +41,16 @@ public class DownloadServlet extends HttpServlet {
out.close();
in.close();
// 获取当前会话
HttpSession session = request.getSession();
// 从会话中获取学生对象
Student student= (Student)session.getAttribute("student");
// 从会话中获取管理员对象
Admin admin= (Admin)session.getAttribute("admin");
// 从会话中获取教师对象
Teacher teacher= (Teacher)session.getAttribute("teacher");
// 如果会话中存在学生对象,且不存在管理员对象和教师对象,则跳转到学生查找文件列表页面
if (student != null && admin == null && teacher == null) {
request.getRequestDispatcher("/WEB-INF/student/sFindFileList.jsp").forward(request, response);
// 如果会话中存在管理员对象,且不存在学生对象和教师对象,则跳转到管理员查找文件列表页面
} else if (admin != null && student == null && teacher == null) {
request.getRequestDispatcher("/WEB-INF/admin/aFindFileList.jsp").forward(request, response);
// 如果会话中存在教师对象,且不存在学生对象和管理员对象,则跳转到教师查找文件列表页面
} else if (teacher != null && admin == null && student == null) {
request.getRequestDispatcher("/WEB-INF/teacher/tFindFileList.jsp").forward(request, response);
// 如果会话中不存在学生对象、管理员对象和教师对象,则跳转到错误页面
} else {
request.getRequestDispatcher("error.jsp").forward(request, response);
}
@ -91,92 +60,3 @@ public class DownloadServlet extends HttpServlet {
doPost(request, response);
}
}
//package web.servlet.file;
//
//import domain.Admin;
//import domain.Student;
//import domain.Teacher;
//
//import javax.servlet.ServletException;
//import javax.servlet.ServletOutputStream;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//import java.io.InputStream;
//import java.net.URLEncoder;
///**
// * 文件下载的Servlet
// */
//@WebServlet("/downloadServlet")
//public class DownloadServlet extends HttpServlet {
// /**
// * 处理POST请求执行文件下载操作。
// *
// * @param request HTTP请求对象包含客户端发送的数据。
// * @param response HTTP响应对象用于生成返回给客户端的响应。
// * @throws ServletException 如果处理请求时发生错误。
// * @throws IOException 如果输入或输出异常发生。
// */
// // 处理POST请求
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 获取请求参数filename
// String filename = request.getParameter("filename");
// // 判断filename是否为../或/
// if (filename.equalsIgnoreCase("../") || filename.equalsIgnoreCase("/")) {
// // 如果是则转发到error.jsp页面
// request.getRequestDispatcher("error.jsp").forward(request, response);
// }
// // 设置响应头content-Type为application/octet-stream
// response.addHeader("content-Type", "application/octet-stream");
//
// // 获取请求头User-Agent
// String agent = request.getHeader("User-Agent");
//
// // 判断User-Agent是否包含chrome
// if (agent.toLowerCase().indexOf("chrome") > 0) {
// // 如果包含则设置响应头content-Disposition为attachment;filename并将filename进行UTF-8和ISO8859-1编码
// response.addHeader("content-Disposition", "attachment;filename=" + new String(filename.getBytes("UTF-8"), "ISO8859-1"));
// } else {
// // 如果不包含则设置响应头content-Disposition为attachment;filename并将filename进行UTF-8编码
// response.addHeader("content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
// }
// InputStream in = getServletContext().getResourceAsStream("/upload/" + filename);
// ServletOutputStream out = response.getOutputStream();
// byte[] bs = new byte[1024];
// int len = -1;
// while ((len = in.read(bs)) != -1) {
// out.write(bs, 0, len);
// }
// out.close();
// in.close();
//
// // 获取当前会话
// HttpSession session = request.getSession();
// // 从会话中获取学生对象
// Student student= (Student)session.getAttribute("student");
// // 从会话中获取管理员对象
// Admin admin= (Admin)session.getAttribute("admin");
// // 从会话中获取教师对象
// Teacher teacher= (Teacher)session.getAttribute("teacher");
// // 如果会话中存在学生对象,且不存在管理员对象和教师对象,则跳转到学生查找文件列表页面
// if (student != null && admin == null && teacher == null) {
// request.getRequestDispatcher("/WEB-INF/student/sFindFileList.jsp").forward(request, response);
// // 如果会话中存在管理员对象,且不存在学生对象和教师对象,则跳转到管理员查找文件列表页面
// } else if (admin != null && student == null && teacher == null) {
// request.getRequestDispatcher("/WEB-INF/admin/aFindFileList.jsp").forward(request, response);
// // 如果会话中存在教师对象,且不存在学生对象和管理员对象,则跳转到教师查找文件列表页面
// } else if (teacher != null && admin == null && student == null) {
// request.getRequestDispatcher("/WEB-INF/teacher/tFindFileList.jsp").forward(request, response);
// // 如果会话中不存在学生对象、管理员对象和教师对象,则跳转到错误页面
// } else {
// request.getRequestDispatcher("error.jsp").forward(request, response);
// }
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request, response);
// }
//}

@ -20,38 +20,23 @@ import java.util.List;
@WebServlet("/fileListServlet")
public class FileListServlet extends HttpServlet {
// 处理POST请求
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求编码为utf-8
request.setCharacterEncoding("utf-8");
// 获取上传文件的目录
File dir = new File(this.getServletContext().getRealPath("upload"));
// 如果目录不存在且不是目录
if (!dir.exists() && !dir.isDirectory()) {
// 输出提示信息
System.out.println(this.getServletContext().getRealPath("upload") + "目录不存在,需要创建");
// 创建目录
dir.mkdir();
}
// 获取目录下的所有文件
File[] arrs = dir.listFiles();
// 创建一个List来存储文件信息
List<FileClass> fileLists = new ArrayList<FileClass>();
// 遍历所有文件
for(File f:arrs){
// 获取文件大小
long l = f.length();
// 将文件大小转换为可读的格式
String fileSize = getPrintSize(l);
// 创建一个FileClass对象
FileClass file = new FileClass();
// 设置文件名
file.setFileName(f.getName());
// 设置文件路径
file.setFilePath(f.getAbsolutePath());
// 设置文件大小
file.setFileSize(fileSize);
// 将文件信息添加到List中
fileLists.add(file);
}
request.setAttribute("fileLists",fileLists);
@ -59,20 +44,14 @@ public class FileListServlet extends HttpServlet {
HttpSession session = request.getSession();
Student student= (Student)session.getAttribute("student");
// 从session中获取admin对象
Admin admin= (Admin)session.getAttribute("admin");
// 从session中获取teacher对象
Teacher teacher= (Teacher)session.getAttribute("teacher");
// 如果student对象不为空admin对象为空teacher对象为空则跳转到student的文件列表页面
if (student != null && admin == null && teacher == null) {
request.getRequestDispatcher("/WEB-INF/student/sFindFileList.jsp").forward(request, response);
// 如果admin对象不为空student对象为空teacher对象为空则跳转到admin的文件列表页面
} else if (admin != null && student == null && teacher == null) {
request.getRequestDispatcher("/WEB-INF/admin/aFindFileList.jsp").forward(request, response);
// 如果teacher对象不为空admin对象为空student对象为空则跳转到teacher的文件列表页面
} else if (teacher != null && admin == null && student == null) {
request.getRequestDispatcher("/WEB-INF/teacher/tFindFileList.jsp").forward(request, response);
// 否则跳转到错误页面
} else {
request.getRequestDispatcher("error.jsp").forward(request, response);
}
@ -107,112 +86,3 @@ public class FileListServlet extends HttpServlet {
}
}
}
//package web.servlet.file;
//
//import domain.Admin;
//import domain.FileClass;
//import domain.Student;
//import domain.Teacher;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.File;
//import java.io.IOException;
//import java.math.BigDecimal;
//import java.math.RoundingMode;
//import java.util.ArrayList;
//import java.util.List;
//
//@WebServlet("/fileListServlet")
//public class FileListServlet extends HttpServlet {
// // 处理POST请求
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求编码为utf-8
// request.setCharacterEncoding("utf-8");
// // 获取上传文件的目录
// File dir = new File(this.getServletContext().getRealPath("upload"));
// // 如果目录不存在且不是目录
// if (!dir.exists() && !dir.isDirectory()) {
// // 输出提示信息
// System.out.println(this.getServletContext().getRealPath("upload") + "目录不存在,需要创建");
// // 创建目录-
// dir.mkdir();
// }
// // 获取目录下的所有文件
// File[] arrs = dir.listFiles();
// // 创建一个List来存储文件信息
// List<FileClass> fileLists = new ArrayList<FileClass>();
// // 遍历所有文件
// for(File f:arrs){
// // 获取文件大小
// long l = f.length();
// // 将文件大小转换为可读的格式
// String fileSize = getPrintSize(l);
// // 创建一个FileClass对象
// FileClass file = new FileClass();
// // 设置文件名
// file.setFileName(f.getName());
// // 设置文件路径
// file.setFilePath(f.getAbsolutePath());
// // 设置文件大小
// file.setFileSize(fileSize);
// // 将文件信息添加到List中
// fileLists.add(file);
// }
// request.setAttribute("fileLists",fileLists);
//
// HttpSession session = request.getSession();
// Student student= (Student)session.getAttribute("student");
//
// // 从session中获取admin对象
// Admin admin= (Admin)session.getAttribute("admin");
// // 从session中获取teacher对象
// Teacher teacher= (Teacher)session.getAttribute("teacher");
// // 如果student对象不为空admin对象为空teacher对象为空则跳转到student的文件列表页面
// if (student != null && admin == null && teacher == null) {
// request.getRequestDispatcher("/WEB-INF/student/sFindFileList.jsp").forward(request, response);
// // 如果admin对象不为空student对象为空teacher对象为空则跳转到admin的文件列表页面
// } else if (admin != null && student == null && teacher == null) {
// request.getRequestDispatcher("/WEB-INF/admin/aFindFileList.jsp").forward(request, response);
// // 如果teacher对象不为空admin对象为空student对象为空则跳转到teacher的文件列表页面
// } else if (teacher != null && admin == null && student == null) {
// request.getRequestDispatcher("/WEB-INF/teacher/tFindFileList.jsp").forward(request, response);
// // 否则跳转到错误页面
// } else {
// request.getRequestDispatcher("error.jsp").forward(request, response);
// }
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//
// public static String getPrintSize(long size) {
// // 如果字节数少于1024则直接以B为单位否则先除于1024后3位因太少无意义-
// double value = (double) size;
// if (value < 1024) {
// return String.valueOf(value) + "B";
// } else {
// value = new BigDecimal(value / 1024).setScale(2, BigDecimal.ROUND_DOWN).doubleValue();
// }
// // 如果原字节数除于1024之后少于1024则可以直接以KB作为单位-
// // 因为还没有到达要使用另一个单位的时候
// // 接下去以此类推
// if (value < 1024) {
// return String.valueOf(value) + "KB";
// } else {
// value = new BigDecimal(value / 1024).setScale(2, BigDecimal.ROUND_DOWN).doubleValue();
// }
// if (value < 1024) {
// return String.valueOf(value) + "MB";
// } else {
// // 否则如果要以GB为单位的先除于1024再作同样的处理
// value = new BigDecimal(value / 1024).setScale(2, BigDecimal.ROUND_DOWN).doubleValue();
// return String.valueOf(value) + "GB";
// }
// }
//}

@ -17,40 +17,3 @@ public class FileServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.file;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
///**
// * 文件处理的Servlet用于转发到文件上传页面
// */
//@WebServlet("/fileServlet")
//public class FileServlet extends HttpServlet {
// /**
// * 处理POST请求转发到文件上传页面。
// *
// * @param request HTTP请求对象包含客户端发送的数据。
// * @param response HTTP响应对象用于生成返回给客户端的响应。
// * @throws ServletException 如果处理请求时发生错误。
// * @throws IOException 如果输入或输出异常发生。
// */
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.getRequestDispatcher("/WEB-INF/admin/uploadFile.jsp").forward(request,response);
// }
//
// /**
// * 处理GET请求直接调用POST请求处理方法。
// *
// * @param request HTTP请求对象包含客户端发送的数据。
// * @param response HTTP响应对象用于生成返回给客户端的响应。
// * @throws ServletException 如果处理请求时发生错误。
// * @throws IOException 如果输入或输出异常发生。
// */
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -34,23 +34,18 @@ public class ShowPhotoServlet extends HttpServlet {
Student student = (Student) session.getAttribute("student");
Teacher teacher = (Teacher) session.getAttribute("teacher");
Photo p;
// 判断当前用户是学生还是教师
if (student != null) {
// 如果是学生则根据学生id查询照片
PhotoService service = new PhotoServiceImpl();
p = service.findPhotoByPhotoId(student.getS_id());
}else{
// 如果是教师则根据教师id查询照片
PhotoService service = new PhotoServiceImpl();
p = service.findPhotoByPhotoId(teacher.getT_id());
}
String imagePath = "";
// 如果没有查询到照片,则使用默认照片
if (p == null) {
imagePath = this.getServletContext().getRealPath("/photos/") + "0.jpg";
System.out.println(imagePath);
} else {
// 如果查询到照片,则使用查询到的照片
String photoName = p.getPhotoName();
imagePath = this.getServletContext().getRealPath("/photos/") + photoName;
System.out.println(imagePath);
@ -77,20 +72,14 @@ public class ShowPhotoServlet extends HttpServlet {
imageIn.close();// 关闭文件流
}
if (imagePath.toLowerCase().endsWith(".gif"))
// 不使用编码处理文件流的情况:
if (imagePath.toLowerCase().endsWith(".gif"))// 不使用编码处理文件流的情况:
{
response.setContentType(GIF);
ServletContext context = getServletContext();
// 得到背景对象
InputStream imageIn = context.getResourceAsStream(imagePath);
// 文件流
BufferedInputStream bis = new BufferedInputStream(imageIn);
// 输入缓冲流
BufferedOutputStream bos = new BufferedOutputStream(output);
// 输出缓冲流
byte data[] = new byte[4096];
// 缓冲字节数
ServletContext context = getServletContext();// 得到背景对象
InputStream imageIn = context.getResourceAsStream(imagePath);// 文件流
BufferedInputStream bis = new BufferedInputStream(imageIn);// 输入缓冲流
BufferedOutputStream bos = new BufferedOutputStream(output);// 输出缓冲流
byte data[] = new byte[4096];// 缓冲字节数
int size = 0;
size = bis.read(data);
while (size != -1) {
@ -108,113 +97,3 @@ public class ShowPhotoServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.file;
//
//import com.sun.image.codec.jpeg.JPEGCodec;
//import com.sun.image.codec.jpeg.JPEGImageDecoder;
//import com.sun.image.codec.jpeg.JPEGImageEncoder;
//import domain.Photo;
//import domain.Student;
//import domain.Teacher;
//import service.PhotoService;
//import service.impl.PhotoServiceImpl;
//
//import javax.servlet.ServletContext;
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.awt.image.BufferedImage;
//import java.io.*;
//import java.net.ServerSocket;
//
//@WebServlet("/showPhotoServlet")
//public class ShowPhotoServlet extends HttpServlet {
// private static final String GIF = "image/gif;charset=GB2312";// 设定输出的类型
//
// private static final String JPG = "image/jpeg;charset=GB2312";
//
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// String spec = request.getParameter("spec");// 输出图片的类型的标志
//
// request.setCharacterEncoding("utf-8");
// HttpSession session = request.getSession();
// Student student = (Student) session.getAttribute("student");
// Teacher teacher = (Teacher) session.getAttribute("teacher");
// Photo p;
// // 判断当前用户是学生还是教师
// if (student != null) {
// // 如果是学生则根据学生id查询照片
// PhotoService service = new PhotoServiceImpl();
// p = service.findPhotoByPhotoId(student.getS_id());
// }else{
// // 如果是教师则根据教师id查询照片
// PhotoService service = new PhotoServiceImpl();
// p = service.findPhotoByPhotoId(teacher.getT_id());
// }
// String imagePath = "";
// // 如果没有查询到照片,则使用默认照片
// if (p == null) {
// imagePath = this.getServletContext().getRealPath("/photos/") + "0.jpg";
// System.out.println(imagePath);
// } else {
// // 如果查询到照片,则使用查询到的照片
// String photoName = p.getPhotoName();
// imagePath = this.getServletContext().getRealPath("/photos/") + photoName;
// System.out.println(imagePath);
// }
//
//
// response.reset();
//
// OutputStream output = response.getOutputStream();// 得到输出流
// if (imagePath.toLowerCase().endsWith(".jpg"))// 使用编码处理文件流的情况:
// {
// response.setContentType(JPG);// 设定输出的类型
// // 得到图片的真实路径-
//
// // 得到图片的文件流-
// InputStream imageIn = new FileInputStream(new File(imagePath));
// // 得到输入的编码器将文件流进行jpg格式编码-
// JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(imageIn);
// // 得到编码后的图片对象-
// BufferedImage image = decoder.decodeAsBufferedImage();
// // 得到输出的编码器
// JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(output);
// encoder.encode(image);// 对图片进行输出编码
// imageIn.close();// 关闭文件流
// }
//
// if (imagePath.toLowerCase().endsWith(".gif"))
// // 不使用编码处理文件流的情况:
// {
// response.setContentType(GIF);
// ServletContext context = getServletContext();
// // 得到背景对象
// InputStream imageIn = context.getResourceAsStream(imagePath);
// // 文件流
// BufferedInputStream bis = new BufferedInputStream(imageIn);
// // 输入缓冲流
// BufferedOutputStream bos = new BufferedOutputStream(output);
// // 输出缓冲流
// byte data[] = new byte[4096];
// // 缓冲字节数
// int size = 0;
// size = bis.read(data);
// while (size != -1) {
// bos.write(data, 0, size);
// size = bis.read(data);
// }
// bis.close();
// bos.flush();// 清空输出缓冲流
// bos.close();
// }
// output.close();
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -26,22 +26,14 @@ import java.util.List;
@WebServlet("/uploadImageServlet")
public class UploadImageServlet extends HttpServlet {
// 处理POST请求
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 获取当前会话
HttpSession session = request.getSession();
// 获取当前会话中的学生对象
Student student = (Student) session.getAttribute("student");
// 获取当前会话中的教师对象
Teacher teacher = (Teacher) session.getAttribute("teacher");
// 获取当前会话中的管理员对象
Admin admin = (Admin) session.getAttribute("admin");
// 定义一个字符串变量用于存储用户ID
String id = "";
// 如果当前会话中有学生对象
if (student != null) {
// 将学生ID赋值给id变量
id = student.getS_id();
}
@ -87,7 +79,6 @@ public class UploadImageServlet extends HttpServlet {
filename = filename.substring(filename.lastIndexOf("\\") + 1);
// System.out.print(filename);
// 判断文件名后缀是否为JPG、JPEG、gif、GIF、jpg、jpeg
if (filename.substring(filename.lastIndexOf(".") + 1).equals("JPG")
|| filename.substring(filename.lastIndexOf(".") + 1).equals("JPEG")
|| filename.substring(filename.lastIndexOf(".") + 1).equals("gif")
@ -110,7 +101,6 @@ public class UploadImageServlet extends HttpServlet {
} else { //必须是图片才能上传否则失败
request.setAttribute("update_msg", "上传失败只能上传类型为jpg或GIF的图像文件"+String.format("%tT",new Date()));
// request.getRequestDispatcher("/WEB-INF/index.jsp").forward(request, response);
// 转发到studentAddPhoto.jsp页面
request.getRequestDispatcher("/WEB-INF/student/studentAddPhoto.jsp").forward(request, response);
return;
}
@ -119,13 +109,9 @@ public class UploadImageServlet extends HttpServlet {
e.printStackTrace();
}
// 创建Photo对象
Photo photo = new Photo();
// 设置photoId
photo.setPhotoId(id);
// 设置photoName
photo.setPhotoName(newFileName);
// 创建PhotoService对象
PhotoService service = new PhotoServiceImpl();
@ -144,149 +130,3 @@ public class UploadImageServlet extends HttpServlet {
request.getRequestDispatcher("/WEB-INF/student/studentAddPhoto.jsp").forward(request, response);
}
}
//package web.servlet.file;
//
//import domain.Admin;
//import domain.Photo;
//import domain.Student;
//import domain.Teacher;
//import org.apache.commons.fileupload.FileItem;
//import org.apache.commons.fileupload.FileUploadException;
//import org.apache.commons.fileupload.disk.DiskFileItemFactory;
//import org.apache.commons.fileupload.servlet.ServletFileUpload;
//import service.PhotoService;
//import service.impl.PhotoServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.File;
//import java.io.FileOutputStream;
//import java.io.IOException;
//import java.io.InputStream;
//import java.util.Date;
//import java.util.List;
//
//@WebServlet("/uploadImageServlet")
//public class UploadImageServlet extends HttpServlet {
// // 处理POST请求
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//
// // 获取当前会话
// HttpSession session = request.getSession();
// // 获取当前会话中的学生对象
// Student student = (Student) session.getAttribute("student");
// // 获取当前会话中的教师对象
// Teacher teacher = (Teacher) session.getAttribute("teacher");
// // 获取当前会话中的管理员对象
// Admin admin = (Admin) session.getAttribute("admin");
// // 定义一个字符串变量用于存储用户ID
// String id = "";
// // 如果当前会话中有学生对象
// if (student != null) {
// // 将学生ID赋值给id变量
// id = student.getS_id();
// }
//
// request.setAttribute("message", "");
// request.setAttribute("path", "");
// String filename = null;
// String newFileName = null;
// // 设置上传图片的保存路径-
// String savePath = this.getServletContext().getRealPath("/photos");
// File file = new File(savePath);
// // 判断上传文件的保存目录是否存在-
// if (!file.exists() && !file.isDirectory()) {
// System.out.println(savePath + "目录不存在,需要创建");
// // 创建目录
// file.mkdir();
// }
// DiskFileItemFactory factory = new DiskFileItemFactory();
// // 2、创建一个文件上传解析器-
// ServletFileUpload upload = new ServletFileUpload(factory);
// upload.setHeaderEncoding("UTF-8");
// // 3、判断提交上来的数据是否是上传表单的数据-
// if (!ServletFileUpload.isMultipartContent(request)) {
// // 按照传统方式获取数据-
// return;
// }
// try {
// List<FileItem> list = upload.parseRequest(request);
// System.out.println(list.toString());// 文件的路径 以及保存的路径-
// for (FileItem item : list) {
// filename = item.getName();// 获得一个项的文件名称-
// try {
// newFileName = id + filename.substring(filename.lastIndexOf("."));
// filename = id + filename.substring(filename.lastIndexOf("."));
// } catch (Exception e) {
// e.printStackTrace();
// }
// if (filename == null || filename.trim().equals("")) {// 如果為空則跳過
// continue;
// }
// // 報錯 需要過濾文件名稱 java.io.FileNotFoundException:
// // G:\测试02\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\FaceUp\WEB-INF\images\C:\Users\Ray\Pictures\2.jpeg
// // (文件名、目录名或卷标语法不正确。)
//
// filename = filename.substring(filename.lastIndexOf("\\") + 1);
//// System.out.print(filename);
// // 判断文件名后缀是否为JPG、JPEG、gif、GIF、jpg、jpeg
// if (filename.substring(filename.lastIndexOf(".") + 1).equals("JPG")
// || filename.substring(filename.lastIndexOf(".") + 1).equals("JPEG")
// || filename.substring(filename.lastIndexOf(".") + 1).equals("gif")
// || filename.substring(filename.lastIndexOf(".") + 1).equals("GIF")
// || filename.substring(filename.lastIndexOf(".") + 1).equals("jpg")
// || filename.substring(filename.lastIndexOf(".") + 1).equals("jpeg")) {
// InputStream in = item.getInputStream();// 獲得上傳的輸入流
// FileOutputStream out = new FileOutputStream(savePath + "\\" + filename);// 指定web-inf目錄下的images文件
// request.setAttribute("path", "photos"+"\\" + filename);
//
// int len = 0;
// byte buffer[] = new byte[1024];
// while ((len = in.read(buffer)) > 0)// 每次讀取
// {
// out.write(buffer, 0, len);
// }
// in.close();
// out.close();
// item.delete();
// } else { //必须是图片才能上传否则失败
// request.setAttribute("update_msg", "上传失败只能上传类型为jpg或GIF的图像文件"+String.format("%tT",new Date()));
//// request.getRequestDispatcher("/WEB-INF/index.jsp").forward(request, response);
// // 转发到studentAddPhoto.jsp页面
// request.getRequestDispatcher("/WEB-INF/student/studentAddPhoto.jsp").forward(request, response);
// return;
// }
// }
// } catch (FileUploadException e) {
// e.printStackTrace();
// }
//
// // 创建Photo对象
// Photo photo = new Photo();
// // 设置photoId
// photo.setPhotoId(id);
// // 设置photoName
// photo.setPhotoName(newFileName);
// // 创建PhotoService对象
// PhotoService service = new PhotoServiceImpl();
//
//
// Photo photo1= service.findPhotoByPhotoId(id);
// if (photo1==null) {
// service.addPhoto(photo);
// }else {
// service.updatePhoto(photo);
// }
// request.setAttribute("update_msg", "上传成功!"+String.format("%tT",new Date()));
//// request.getRequestDispatcher("/WEB-INF/index.jsp").forward(request, response);
// request.getRequestDispatcher("/WEB-INF/student/studentAddPhoto.jsp").forward(request, response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.getRequestDispatcher("/WEB-INF/student/studentAddPhoto.jsp").forward(request, response);
// }
//}

@ -18,40 +18,16 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload;
@WebServlet("/uploadServlet")
public class UploadServlet extends HttpServlet {
<<<<<<< HEAD
=======
/**
* POST
*
* @param request HTTP
* @param response HTTP
* @throws ServletException
* @throws IOException
*/
// 处理POST请求
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求编码为utf-8
request.setCharacterEncoding("utf-8");
// 设置响应编码为utf-8
response.setCharacterEncoding("utf-8");
// 设置响应内容类型为text/html编码为utf-8
response.setContentType("text/html; charset=utf-8");
// 判断请求是否为文件上传
boolean isMultipart=ServletFileUpload.isMultipartContent(request);
// 如果是文件上传
if (isMultipart) {
// 创建一个文件项工厂
FileItemFactory factory = new DiskFileItemFactory();
// 创建一个文件上传对象
ServletFileUpload upload = new ServletFileUpload(factory);
// 设置文件上传对象的编码为utf-8
upload.setHeaderEncoding("utf-8");
// upload.setProgressListener(new ProgressListener(){
@ -67,17 +43,11 @@ public class UploadServlet extends HttpServlet {
// });
try {
// 解析请求,获取上传的文件项
List<FileItem> items = upload.parseRequest(request);
// 获取文件项的迭代器
Iterator<FileItem> it = items.iterator();
// 遍历文件项
while (it.hasNext()) {
// 获取下一个文件项
FileItem item = it.next();
// 获取文件项的名称
String itemname = item.getFieldName();
// 初始化学号和姓名
int sno = -1;
String sname = null;
@ -93,31 +63,21 @@ public class UploadServlet extends HttpServlet {
} else {
String filename = item.getName();
//String path=request.getSession().getServletContext().getRealPath("upload");
// 获取上传文件的路径
String path = this.getServletContext().getRealPath("upload");
// 判断上传文件的扩展名是否为jsp、htm或html
if (filename.substring(filename.lastIndexOf(".") + 1).equals("jsp")
|| filename.substring(filename.lastIndexOf(".") + 1).equals("htm")
|| filename.substring(filename.lastIndexOf(".") + 1).equals("html")) {
// 如果是,则转发到错误页面
request.getRequestDispatcher("error.jsp").forward(request, response);
} else {
// 如果不是,则打印上传文件的路径
System.out.println(path);
// 创建文件对象
File file = new File(path);
// 如果文件不存在且不是目录,则创建目录
if (!file.exists() && !file.isDirectory()) {
file.mkdir();
}
// 将上传的文件写入到指定路径
item.write(new File(path, filename));
// 设置上传成功的属性
request.setAttribute("news", filename + " 上传成功!");
// 转发到上传成功页面
request.getRequestDispatcher("/WEB-INF/admin/uploadFile.jsp").forward(request, response);
// response.sendRedirect("fileUploadIndexServlet");
// 打印上传成功的消息
System.out.println(filename + "上传成功!!!");
}
@ -133,26 +93,11 @@ public class UploadServlet extends HttpServlet {
}
}
<<<<<<< HEAD
=======
/**
*
*/
// 定义一个ProcessInfo类用于存储进程信息
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
class ProcessInfo{
// 总大小
public long totalSize = 1;
// 已读大小
public long readSize = 0;
// 显示信息
public String show = "";
// 项目数量
public int itemNum = 0;
// 速率
public int rate = 0;
}
@ -160,155 +105,3 @@ public class UploadServlet extends HttpServlet {
doPost(request, response);
}
}
//package web.servlet.file;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.File;
//import java.util.Iterator;
//import java.util.List;
//import org.apache.commons.fileupload.FileItem;
//import org.apache.commons.fileupload.FileItemFactory;
//import org.apache.commons.fileupload.FileUploadException;
//import org.apache.commons.fileupload.ProgressListener;
//import org.apache.commons.fileupload.disk.DiskFileItemFactory;
//import org.apache.commons.fileupload.servlet.ServletFileUpload;
///**
// * 文件上传的Servlet
// */
//@WebServlet("/uploadServlet")
//public class UploadServlet extends HttpServlet {
//
// /**
// * 处理POST请求用于执行文件上传操作。
// *
// * @param request HTTP请求对象包含客户端发送的数据。
// * @param response HTTP响应对象用于生成返回给客户端的响应。
// * @throws ServletException 如果处理请求时发生错误。
// * @throws IOException 如果输入或输出异常发生。
// */
// // 处理POST请求
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求编码为utf-8
// request.setCharacterEncoding("utf-8");
// // 设置响应编码为utf-8
// response.setCharacterEncoding("utf-8");
// // 设置响应内容类型为text/html编码为utf-8
// response.setContentType("text/html; charset=utf-8");
//
//
// // 判断请求是否为文件上传
// boolean isMultipart=ServletFileUpload.isMultipartContent(request);
// // 如果是文件上传
// if (isMultipart) {
// // 创建一个文件项工厂
// FileItemFactory factory = new DiskFileItemFactory();
// // 创建一个文件上传对象
// ServletFileUpload upload = new ServletFileUpload(factory);
// // 设置文件上传对象的编码为utf-8
// upload.setHeaderEncoding("utf-8");
//
//// upload.setProgressListener(new ProgressListener(){
//// public void update(long pBytesRead, long pContentLength, int pItems) {
//// ProcessInfo pri = new ProcessInfo();
//// pri.itemNum = pItems;
//// pri.readSize = pBytesRead;
//// pri.totalSize = pContentLength;
//// pri.show = pBytesRead+"/"+pContentLength+" byte";
//// pri.rate = Math.round(new Float(pBytesRead) / new Float(pContentLength)*100);
//// hs.setAttribute("proInfo", pri);
//// }
//// });
//
// try {
// // 解析请求,获取上传的文件项
// List<FileItem> items = upload.parseRequest(request);
// // 获取文件项的迭代器
// Iterator<FileItem> it = items.iterator();
// // 遍历文件项
// while (it.hasNext()) {
// // 获取下一个文件项
// FileItem item = it.next();
// // 获取文件项的名称
// String itemname = item.getFieldName();
// // 初始化学号和姓名
// int sno = -1;
// String sname = null;
//
// if (item.isFormField()) {
// if (itemname.equals("sno")) {
// sno = Integer.parseInt(item.getString("utf-8"));
// } else if (itemname.equals("sname")) {
// sname = item.getString("utf-8");
// sname = item.getName();
// } else {
// System.out.println("其他字段");
// }
// } else {
// String filename = item.getName();
// //String path=request.getSession().getServletContext().getRealPath("upload");
// // 获取上传文件的路径
// String path = this.getServletContext().getRealPath("upload");
// // 判断上传文件的扩展名是否为jsp、htm或html
// if (filename.substring(filename.lastIndexOf(".") + 1).equals("jsp")
// || filename.substring(filename.lastIndexOf(".") + 1).equals("htm")
// || filename.substring(filename.lastIndexOf(".") + 1).equals("html")) {
// // 如果是,则转发到错误页面
// request.getRequestDispatcher("error.jsp").forward(request, response);
// } else {
// // 如果不是,则打印上传文件的路径
// System.out.println(path);
// // 创建文件对象
// File file = new File(path);
// // 如果文件不存在且不是目录,则创建目录
// if (!file.exists() && !file.isDirectory()) {
// file.mkdir();
// }
// // 将上传的文件写入到指定路径
// item.write(new File(path, filename));
// // 设置上传成功的属性
// request.setAttribute("news", filename + " 上传成功!");
// // 转发到上传成功页面
// request.getRequestDispatcher("/WEB-INF/admin/uploadFile.jsp").forward(request, response);
//// response.sendRedirect("fileUploadIndexServlet");
// // 打印上传成功的消息
// System.out.println(filename + "上传成功!!!");
//
// }
// return;
// }
//
// }
// } catch (FileUploadException e) {
// e.printStackTrace();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// /**
// * 表示文件上传或下载过程中的信息类
// */
// // 定义一个ProcessInfo类用于存储进程信息
// class ProcessInfo{
// // 总大小
// public long totalSize = 1;
// // 已读大小
// public long readSize = 0;
// // 显示信息
// public String show = "";
// // 项目数量
// public int itemNum = 0;
// // 速率
// public int rate = 0;
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request, response);
// }
//}

@ -10,35 +10,13 @@ import java.io.IOException;
@WebServlet("/logoutServlet")
public class LogoutServlet extends HttpServlet {
<<<<<<< HEAD
=======
/**
* POST
*
* @param request HTTP
* @param response HTTP
* @throws ServletException
* @throws IOException
*/
// 处理POST请求
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求编码为UTF-8
request.setCharacterEncoding("UTF-8");
// 获取当前会话
HttpSession session = request.getSession();
// 移除会话中的student属性
session.removeAttribute("student");
// 移除会话中的teacher属性
session.removeAttribute("teacher");
// 移除会话中的admin属性
session.removeAttribute("admin");
// 使会话失效
session.invalidate();
// 重定向到index.jsp页面
response.sendRedirect("index.jsp");
}

@ -13,56 +13,32 @@ import java.io.IOException;
public class RegisterServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession();
// 获取用户输入的学生ID
String studentid = request.getParameter("studentid");
// 获取用户输入的密码
String password = request.getParameter("password");
// 获取用户输入的确认密码
String repassword = request.getParameter("repassword");
// 获取用户输入的验证码
String vcode = request.getParameter("verifycode");
//从session中获取服务器生成的验证码
String checkcode_server = (String) session.getAttribute("CHECKCODE_SERVER");
session.removeAttribute("CHECKCODE_SERVER");
//确保验证一次性
// 判断验证码是否正确
session.removeAttribute("CHECKCODE_SERVER");//确保验证一次性
if (!vcode.equalsIgnoreCase(checkcode_server)){
// 如果验证码错误将错误信息、用户输入的信息存入request中
request.setAttribute("msg","验证码错误");
// 将用户输入的学号存入request中
request.setAttribute("studentid",studentid);
// 将用户输入的密码存入request中
request.setAttribute("password",password);
// 将用户输入的确认密码存入request中
request.setAttribute("repassword",repassword);
// 将请求转发到register.jsp页面
request.getRequestDispatcher("register.jsp").forward(request,response);
// 返回
return;
}else {
Student student = new Student();
// 设置学生id
student.setS_id(studentid);
// 设置学生密码
student.setS_password(password);
// 打印学生id
System.out.println(studentid);
// 打印学生密码
System.out.println(password);
// 创建学生服务对象
StudentService service= new StudentServiceImpl();
// 调用注册方法
service.register(student);
// 设置注册成功信息
request.setAttribute("msg","注册成功");
// 清空学生id
request.setAttribute("studentid","");
// 清空学生密码
request.setAttribute("password","");
// 清空确认密码
request.setAttribute("repassword","");
// 转发到注册页面
request.getRequestDispatcher("register.jsp").forward(request,response);
}
@ -72,88 +48,3 @@ public class RegisterServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.login;
//
//import domain.Student;
//import service.StudentService;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.*;
//import java.io.IOException;
///**
// * 用户注册的Servlet
// */
//@WebServlet("/registerServlet")
//public class RegisterServlet extends HttpServlet {
// /**
// * 处理POST请求实现用户注册功能。
// *
// * @param request HTTP请求对象包含客户端发送的数据。
// * @param response HTTP响应对象用于生成返回给客户端的响应。
// * @throws ServletException 如果处理请求时发生错误。
// * @throws IOException 如果输入或输出异常发生。
// */
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 获取当前用户的会话
// HttpSession session = request.getSession();
// // 获取用户输入的学生ID
// String studentid = request.getParameter("studentid");
// // 获取用户输入的密码
// String password = request.getParameter("password");
// // 获取用户输入的确认密码
// String repassword = request.getParameter("repassword");
// // 获取用户输入的验证码
// String vcode = request.getParameter("verifycode");
//
// //从session中获取服务器生成的验证码
// String checkcode_server = (String) session.getAttribute("CHECKCODE_SERVER");
// session.removeAttribute("CHECKCODE_SERVER");
// //确保验证一次性
// // 判断验证码是否正确
// if (!vcode.equalsIgnoreCase(checkcode_server)){
// // 如果验证码错误将错误信息、用户输入的信息存入request中
// request.setAttribute("msg","验证码错误");
// // 将用户输入的学号存入request中
// request.setAttribute("studentid",studentid);
// // 将用户输入的密码存入request中
// request.setAttribute("password",password);
// // 将用户输入的确认密码存入request中
// request.setAttribute("repassword",repassword);
// // 将请求转发到register.jsp页面
// request.getRequestDispatcher("register.jsp").forward(request,response);
// // 返回
// return;
// }else {
// Student student = new Student();
// // 设置学生id
// student.setS_id(studentid);
// // 设置学生密码
// student.setS_password(password);
// // 打印学生id
// System.out.println(studentid);
// // 打印学生密码
// System.out.println(password);
// // 创建学生服务对象
// StudentService service= new StudentServiceImpl();
// // 调用注册方法
// service.register(student);
// // 设置注册成功信息
// request.setAttribute("msg","注册成功");
// // 清空学生id
// request.setAttribute("studentid","");
// // 清空学生密码
// request.setAttribute("password","");
// // 清空确认密码
// request.setAttribute("repassword","");
// // 转发到注册页面
// request.getRequestDispatcher("register.jsp").forward(request,response);
//
// }
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -37,42 +37,3 @@ public class AddNotifyServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.notify;
//
//import domain.Notify;
//import org.apache.commons.beanutils.BeanUtils;
//import service.NotifyService;
//import service.impl.NotifyServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//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.text.SimpleDateFormat;
//import java.util.Date;
//import java.util.List;
//import java.util.Map;
//
//@WebServlet("/addNotifyServlet")
//public class AddNotifyServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.setCharacterEncoding("utf-8");
//
// //获取参数-
// Notify notify = new Notify();
// notify.setNotifyInfo((String) request.getParameter("notifyInfo"));
// Date d = new Date();
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// notify.setNotifyDate(sdf.format(d));
// NotifyService service = new NotifyServiceImpl();
// service.addNotify(notify);
//// response.sendRedirect("/notifyListServlet");
// request.getRequestDispatcher("/notifyListServlet").forward(request,response);
// }
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -27,43 +27,3 @@ public class DeleteNotifyServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.notify;
//
//import domain.Student;
//import service.NotifyService;
//import service.impl.NotifyServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
///**
// * 删除通知的Servlet
// */
//@WebServlet("/deleteNotifyServlet")
//public class DeleteNotifyServlet extends HttpServlet {
// /**
// * 处理POST请求删除指定ID的通知。
// *
// * @param request HTTP请求对象包含客户端发送的数据。
// * @param response HTTP响应对象用于生成返回给客户端的响应。
// * @throws ServletException 如果处理请求时发生错误。
// * @throws IOException 如果输入或输出异常发生。
// */
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求的字符编码为UTF-8以支持中文字符的正确处理
// request.setCharacterEncoding("utf-8");
// HttpSession session = request.getSession();
// String notifyid = request.getParameter("id");
// NotifyService service = new NotifyServiceImpl();
// service.deleteNotifyById(notifyid);
// request.getRequestDispatcher("/notifyListServlet").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -25,42 +25,3 @@ public class NotifyListServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.notify;
//
//import domain.Notify;
//import service.NotifyService;
//import service.impl.NotifyServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.List;
///**
// * 显示通知列表的Servlet
// */
//@WebServlet("/notifyListServlet")
//public class NotifyListServlet extends HttpServlet {
// /**
// * 处理POST请求获取所有通知并转发到通知列表页面。
// *
// * @param request HTTP请求对象包含客户端发送的数据。
// * @param response HTTP响应对象用于生成返回给客户端的响应。
// * @throws ServletException 如果处理请求时发生错误。
// * @throws IOException 如果输入或输出异常发生。
// */
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求的字符编码为UTF-8以支持中文字符的正确处理
// request.setCharacterEncoding("utf-8");
// // 创建通知服务的实例,以便获取通知数据
// NotifyService service = new NotifyServiceImpl();
// List<Notify> notifys = service.findAll();
// request.setAttribute("notifys",notifys);
// request.getRequestDispatcher("/WEB-INF/notify/notifyList.jsp").forward(request,response);
// }
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -24,19 +24,13 @@ public class NotifyListToServlet extends HttpServlet {
List<Notify> notifys = service.findAll();
request.setAttribute("notifys",notifys);
// 获取当前会话
HttpSession session = request.getSession();
// 从会话中获取学生对象
Student student= (Student)session.getAttribute("student");
// 从会话中获取教师对象
Teacher teacher= (Teacher)session.getAttribute("teacher");
// 如果会话中存在学生对象且不存在教师对象,则转发到学生通知列表页面
if (student != null && teacher == null) {
request.getRequestDispatcher("/WEB-INF/notify/notifyListToStudent.jsp").forward(request,response);
// 如果会话中存在教师对象且不存在学生对象,则转发到教师通知列表页面
} else if (teacher != null && student == null) {
request.getRequestDispatcher("/WEB-INF/notify/notifyListToTeacher.jsp").forward(request,response);
// 如果会话中既不存在学生对象也不存在教师对象,则转发到错误页面
} else {
request.getRequestDispatcher("error.jsp").forward(request, response);
}
@ -47,64 +41,3 @@ public class NotifyListToServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.notify;
//
//import domain.Admin;
//import domain.Notify;
//import domain.Student;
//import domain.Teacher;
//import service.NotifyService;
//import service.impl.NotifyServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//import java.util.List;
///**
// * 转发到通知列表的Servlet
// */
//@WebServlet("/notifyListToServlet")
//public class NotifyListToServlet extends HttpServlet {
// /**
// * 处理POST请求获取所有通知并转发到通知列表页面。
// *
// * @param request HTTP请求对象包含客户端发送的数据。
// * @param response HTTP响应对象用于生成返回给客户端的响应。
// * @throws ServletException 如果处理请求时发生错误。
// * @throws IOException 如果输入或输出异常发生。
// */
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求的字符编码为UTF-8以支持中文字符的正确处理
// request.setCharacterEncoding("utf-8");
// // 创建通知服务的实例,以便获取通知数据
// NotifyService service = new NotifyServiceImpl();
// List<Notify> notifys = service.findAll();
// request.setAttribute("notifys",notifys);
//
// // 获取当前会话
// HttpSession session = request.getSession();
// // 从会话中获取学生对象
// Student student= (Student)session.getAttribute("student");
// // 从会话中获取教师对象
// Teacher teacher= (Teacher)session.getAttribute("teacher");
// // 如果会话中存在学生对象且不存在教师对象,则转发到学生通知列表页面
// if (student != null && teacher == null) {
// request.getRequestDispatcher("/WEB-INF/notify/notifyListToStudent.jsp").forward(request,response);
// // 如果会话中存在教师对象且不存在学生对象,则转发到教师通知列表页面
// } else if (teacher != null && student == null) {
// request.getRequestDispatcher("/WEB-INF/notify/notifyListToTeacher.jsp").forward(request,response);
// // 如果会话中既不存在学生对象也不存在教师对象,则转发到错误页面
// } else {
// request.getRequestDispatcher("error.jsp").forward(request, response);
// }
//
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -17,27 +17,3 @@ public class NotifyServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.notify;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//@WebServlet("/notifyServlet")
//public class NotifyServlet extends HttpServlet {
//
// // 处理POST请求的方法
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 将请求转发到指定的JSP页面
// request.getRequestDispatcher("/WEB-INF/notify/addNotify.jsp").forward(request, response);
// }
//
// // 处理GET请求的方法
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 将GET请求转发到doPost方法进行处理
// doPost(request, response);
// }
//}

@ -33,46 +33,23 @@ public class FindStudentByPageServlet extends HttpServlet {
//获取条件查询参数
Map<String,String[]> condition = request.getParameterMap();
//创建StudentService对象
StudentService service = new StudentServiceImpl();
//调用findStudentByPage方法传入当前页码、每页显示的行数和查询条件返回PageBean<Student>对象
PageBean<Student> pb = service.findStudentByPage(currentPage,rows,condition);
//将PageBean<Student>对象存入request域中
request.setAttribute("pb",pb);
<<<<<<< HEAD
<<<<<<< HEAD
request.setAttribute("condition",condition);//存入查询条件
=======
//将查询条件存入request域中
request.setAttribute("condition",condition);//存入查询条件-
//设置request的字符编码为utf-8
>>>>>>> remotes/origin/develop
=======
//将查询条件存入request域中
request.setAttribute("condition",condition);//存入查询条件-
//设置request的字符编码为utf-8
>>>>>>> remotes/origin/develop
request.setCharacterEncoding("utf-8");
//获取session对象
HttpSession session = request.getSession();
//从session中获取Student对象
Student student= (Student)session.getAttribute("student");
// 从session中获取admin对象
Admin admin= (Admin)session.getAttribute("admin");
// 从session中获取teacher对象
Teacher teacher= (Teacher)session.getAttribute("teacher");
// 如果student对象不为空admin对象为空teacher对象为空则跳转到student的查找学生列表页面
if (student != null && admin == null && teacher == null) {
request.getRequestDispatcher("/WEB-INF/student/sFindStudentList.jsp").forward(request, response);
// 如果admin对象不为空student对象为空teacher对象为空则跳转到admin的查找学生列表页面
} else if (admin != null && student == null && teacher == null) {
request.getRequestDispatcher("/WEB-INF/admin/aFindStudentList.jsp").forward(request, response);
// 如果teacher对象不为空admin对象为空student对象为空则跳转到teacher的查找学生列表页面
} else if (teacher != null && admin == null && student == null) {
request.getRequestDispatcher("/WEB-INF/teacher/tFindStudentList.jsp").forward(request, response);
// 否则跳转到错误页面
} else {
request.getRequestDispatcher("error.jsp").forward(request, response);
}
@ -82,79 +59,3 @@ public class FindStudentByPageServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.page;
//
//import domain.Admin;
//import domain.PageBean;
//import domain.Student;
//import domain.Teacher;
//import service.StudentService;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//import java.util.Map;
//
//@WebServlet("/findStudentByPageServlet")
//public class FindStudentByPageServlet extends HttpServlet {
// // 处理POST请求的方法-
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求的字符编码为UTF-8以支持中文字符-
// request.setCharacterEncoding("utf-8");
// String currentPage = request.getParameter("currentPage");//当前页码
// String rows = request.getParameter("rows");//每页显示条数
//
// if (currentPage == null || "".equals(currentPage)) {
// currentPage = "1";
// }
// if (rows == null || "".equals(rows)) {
// rows = "5";
// }
//
// //获取条件查询参数-
// Map<String,String[]> condition = request.getParameterMap();
//
// //创建StudentService对象
// StudentService service = new StudentServiceImpl();
// //调用findStudentByPage方法传入当前页码、每页显示的行数和查询条件返回PageBean<Student>对象
// PageBean<Student> pb = service.findStudentByPage(currentPage,rows,condition);
//
// //将PageBean<Student>对象存入request域中
// request.setAttribute("pb",pb);
// //将查询条件存入request域中
// request.setAttribute("condition",condition);//存入查询条件-
// //设置request的字符编码为utf-8
// request.setCharacterEncoding("utf-8");
// //获取session对象
// HttpSession session = request.getSession();
// //从session中获取Student对象
// Student student= (Student)session.getAttribute("student");
//
// // 从session中获取admin对象
// Admin admin= (Admin)session.getAttribute("admin");
// // 从session中获取teacher对象
// Teacher teacher= (Teacher)session.getAttribute("teacher");
// // 如果student对象不为空admin对象为空teacher对象为空则跳转到student的查找学生列表页面
// if (student != null && admin == null && teacher == null) {
// request.getRequestDispatcher("/WEB-INF/student/sFindStudentList.jsp").forward(request, response);
// // 如果admin对象不为空student对象为空teacher对象为空则跳转到admin的查找学生列表页面
// } else if (admin != null && student == null && teacher == null) {
// request.getRequestDispatcher("/WEB-INF/admin/aFindStudentList.jsp").forward(request, response);
// // 如果teacher对象不为空admin对象为空student对象为空则跳转到teacher的查找学生列表页面
// } else if (teacher != null && admin == null && student == null) {
// request.getRequestDispatcher("/WEB-INF/teacher/tFindStudentList.jsp").forward(request, response);
// // 否则跳转到错误页面
// } else {
// request.getRequestDispatcher("error.jsp").forward(request, response);
// }
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -23,39 +23,3 @@ public class DeleteSelectStudentServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.student;
//
//import service.StudentService;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//@WebServlet("/deleteSelectStudentServlet")
//// 删除选定学生的Servlet
//public class DeleteSelectStudentServlet extends HttpServlet {
//
// // 处理POST请求
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 获取选定学生的ID数组
// String[] sids = request.getParameterValues("sid");
//
// // 创建学生服务的实例
// StudentService service = new StudentServiceImpl();
//
// // 调用服务方法删除选定的学生
// service.deleteSelectStudent(sids);
//
// // 重定向到查找学生的页面
// response.sendRedirect(request.getContextPath() + "/findStudentByPageServlet");
// }
//
// // 处理GET请求直接调用doPost方法
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request, response);
// }
//}

@ -29,50 +29,3 @@ public class DeleteStudentServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.student;
//
//import service.NotifyService;
//import service.StudentService;
//import service.impl.NotifyServiceImpl;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//
//@WebServlet("/deleteStudentServlet")
//// 删除学生的Servlet
//public class DeleteStudentServlet extends HttpServlet {
//
// // 处理POST请求
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求的字符编码为UTF-8
// request.setCharacterEncoding("utf-8");
//
// // 获取当前会话
// HttpSession session = request.getSession();
//
// // 获取要删除的学生ID
// String studentid = request.getParameter("s_id");
//
// // 创建学生服务的实例
// StudentService service = new StudentServiceImpl();
//
// // 调用服务方法通过学生ID删除学生
// service.deleteStudentById(studentid);
//
// // 重定向到查找学生的页面
// response.sendRedirect("findStudentByPageServlet");
// // 如果需要使用转发,可以使用下面的代码
// // request.getRequestDispatcher("/findStudentByPageServlet").forward(request, response);
// }
//
// // 处理GET请求直接调用doPost方法
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request, response);
// }
//}

@ -61,76 +61,3 @@ public class DoSelectCourseServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.student;
//
//import domain.Course;
//import domain.SelectCourse;
//import domain.Student;
//import service.StudentService;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//import java.util.Date;
//import java.util.List;
//
//@WebServlet("/doSelectCourseServlet")
//public class DoSelectCourseServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.setCharacterEncoding("utf-8");
// HttpSession session = request.getSession();
// Student student= (Student)session.getAttribute("student");
// String courseid = request.getParameter("id");
// //存不存在已选该课
// //1
// //2
// //3
// //4
// //5
// //6
// //7
// //8
// //9
// //0
// boolean flag = false;
//
// //判断是否已选
// StudentService studentService = new StudentServiceImpl();
// List<SelectCourse> selectcourses = studentService.findAllSelectCourse(student.getS_id());
// for (SelectCourse s:selectcourses) {
// if (s.getC_id().equals(courseid)) {
// flag = true;
// break;
// }
// }
// if (flag == true) {
//
// request.setAttribute("select_msg", "你已选了该课程!" + String.format("%tT", new Date()));
// request.getRequestDispatcher("studentOptionalCourseServlet").forward(request, response);
//// response.sendRedirect("studentOptionalCourseServlet");
// } else {
// //获取到当前学生id
// String studentid = student.getS_id();
//
// //获取当前行的课程id courseid
//
// //调用学生添加选课服务s_id c_id score select_course添加
// StudentService Service = new StudentServiceImpl();
// Service.addSelectCourse(studentid,courseid);
//
// //完成后给提示跳转
// request.setAttribute("select_msg", "选课成功!" + String.format("%tT", new Date()));
// request.getRequestDispatcher("studentOptionalCourseServlet").forward(request, response);
// }
//
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -20,33 +20,16 @@ public class StudentInfomationUpdateServlet extends HttpServlet {
request.setCharacterEncoding("utf-8");
<<<<<<< HEAD
//保存输入内容
=======
//保存输入内容-
// 获取学生ID
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
String sid = request.getParameter("student-id");
// 获取学生姓名
String name = request.getParameter("student-name");
// 获取学生性别
String sex = request.getParameter("student-sex");
// 获取学生年龄
String age = request.getParameter("student-age");
// 获取学生电话
String phone = request.getParameter("student-phone");
// 获取学生邮箱
String email = request.getParameter("student-email");
// 获取学生地址
String address = request.getParameter("student-address");
// 获取学生所在学院
String college = request.getParameter("selectCollege");
// 获取学生所在系
String department = request.getParameter("selectDepartment");
// 获取学生所在班级
String cclass = request.getParameter("selectClass");
Student updateStudent = new Student();
@ -59,33 +42,16 @@ public class StudentInfomationUpdateServlet extends HttpServlet {
request.getRequestDispatcher("/WEB-INF/student/sInformation.jsp").forward(request, response);
// response.sendRedirect("studentInfomationServlet");
}else {
<<<<<<< HEAD
//封装学生对象
=======
//封装学生对象-
// 设置学生ID
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
updateStudent.setS_id(sid);
// 设置学生姓名
updateStudent.setS_name(name);
// 设置学生性别
updateStudent.setS_sex(sex);
// 设置学生年龄
updateStudent.setS_age(age);
// 设置学生电话
updateStudent.setS_phone(phone);
// 设置学生邮箱
updateStudent.setS_email(email);
// 设置学生地址
updateStudent.setS_address(address);
// 设置学生学院
updateStudent.setS_college(college);
// 设置学生系别
updateStudent.setS_department(department);
// 设置学生班级
updateStudent.setS_class(cclass);
//调用studentUpdata服务
@ -108,119 +74,3 @@ public class StudentInfomationUpdateServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.student;
//
//import domain.Student;
//import service.StudentService;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//import java.text.SimpleDateFormat;
//import java.util.Date;
//
//@WebServlet("/studentInfomationUpdateServlet")
//public class StudentInfomationUpdateServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//
// request.setCharacterEncoding("utf-8");
//
// //保存输入内容-
// // 获取学生ID
// String sid = request.getParameter("student-id");
// // 获取学生姓名
// String name = request.getParameter("student-name");
// // 获取学生性别
// String sex = request.getParameter("student-sex");
// // 获取学生年龄
// String age = request.getParameter("student-age");
// // 获取学生电话
// String phone = request.getParameter("student-phone");
// // 获取学生邮箱
// String email = request.getParameter("student-email");
// // 获取学生地址
// String address = request.getParameter("student-address");
// // 获取学生所在学院
// String college = request.getParameter("selectCollege");
// // 获取学生所在系
// String department = request.getParameter("selectDepartment");
// // 获取学生所在班级
// String cclass = request.getParameter("selectClass");
// //String sid = request.getParameter("student-id");
// // String name = request.getParameter("student-name");
// // String sex = request.getParameter("student-sex");
// // String age = request.getParameter("student-age");
// // String phone = request.getParameter("student-phone");
// // String email = request.getParameter("student-email");
// // String address = request.getParameter("student-address");
// // String college = request.getParameter("selectCollege");
// // String department = request.getParameter("selectDepartment");
// // String cclass = request.getParameter("selectClass");
//
// Student updateStudent = new Student();
//
//
// //判断输入位数是否大于数据库位数-
// if (name.length() > 4 || phone.length() > 11 || email.length()>24 || address.length() > 24 || age.length()>2 || name.contains("<") || phone.contains("<") || email.contains("<") || address.contains("<") || age.contains("<")) {
// request.setAttribute("update_msg","格式错误,请重新提交!"+String.format("%tT",new Date()));
//
// request.getRequestDispatcher("/WEB-INF/student/sInformation.jsp").forward(request, response);
//// response.sendRedirect("studentInfomationServlet");
// }else {
// //封装学生对象-
// // 设置学生ID
// updateStudent.setS_id(sid);
// // 设置学生姓名
// updateStudent.setS_name(name);
// // 设置学生性别
// updateStudent.setS_sex(sex);
// // 设置学生年龄
// updateStudent.setS_age(age);
// // 设置学生电话
// updateStudent.setS_phone(phone);
// // 设置学生邮箱
// updateStudent.setS_email(email);
// // 设置学生地址
// updateStudent.setS_address(address);
// // 设置学生学院
// updateStudent.setS_college(college);
// // 设置学生系别
// updateStudent.setS_department(department);
// // 设置学生班级
// updateStudent.setS_class(cclass);
// //updateStudent.setS_id(sid);
// // updateStudent.setS_name(name);
// // updateStudent.setS_sex(sex);
// // updateStudent.setS_age(age);
// // updateStudent.setS_phone(phone);
// // updateStudent.setS_email(email);
// // updateStudent.setS_address(address);
// // updateStudent.setS_college(college);
// // updateStudent.setS_department(department);
// // updateStudent.setS_class(cclass);
//
// //调用studentUpdata服务-
// StudentService service= new StudentServiceImpl();
// service.updateInfo(updateStudent);
//
// HttpSession session = request.getSession();
//
// Student s = service.findStudentById(updateStudent);
// session.setAttribute("student",s);
//
// //成功则返回并给提示-
// request.setAttribute("update_msg", "修改成功!"+String.format("%tT",new Date()));
// request.setAttribute("student",updateStudent);
// request.getRequestDispatcher("/WEB-INF/student/sInformation.jsp").forward(request, response);
// }
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -26,24 +26,16 @@ public class StudentListServlet extends HttpServlet {
request.setCharacterEncoding("utf-8");
// 获取当前会话
HttpSession session = request.getSession();
// 从会话中获取学生对象
Student student= (Student)session.getAttribute("student");
// 从会话中获取管理员对象
Admin admin= (Admin)session.getAttribute("admin");
// 从会话中获取教师对象
Teacher teacher= (Teacher)session.getAttribute("teacher");
// 如果会话中存在学生对象,且不存在管理员对象和教师对象,则跳转到学生列表页面
if (student != null && admin == null && teacher == null) {
request.getRequestDispatcher("/WEB-INF/student/studentList.jsp").forward(request, response);
// 如果会话中存在管理员对象,且不存在学生对象和教师对象,则跳转到管理员查找学生列表页面
} else if (admin != null && student == null && teacher == null) {
request.getRequestDispatcher("/WEB-INF/admin/aFindStudentList.jsp").forward(request, response);
// 如果会话中存在教师对象,且不存在学生对象和管理员对象,则跳转到教师查找学生列表页面
} else if (teacher != null && admin == null && student == null) {
request.getRequestDispatcher("/WEB-INF/teacher/tFindStudentList.jsp").forward(request, response);
// 如果会话中不存在学生对象、管理员对象和教师对象,则跳转到错误页面
} else {
request.getRequestDispatcher("error.jsp").forward(request, response);
}
@ -53,71 +45,3 @@ public class StudentListServlet extends HttpServlet {
this.doPost(request,response);
}
}
//package web.servlet.student;
//
//import domain.Admin;
//import domain.Student;
//import domain.Teacher;
//import service.StudentService;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//import java.util.List;
//
//@WebServlet("/studentListServlet")
//public class StudentListServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// //调用StudentService完成查询-
// StudentService studentService = new StudentServiceImpl();
// List<Student> students = studentService.findAll();
// //将list存入request域-
// request.setAttribute("students",students);
//
// request.setCharacterEncoding("utf-8");
//
// // 获取当前会话
// HttpSession session = request.getSession();
// // 从会话中获取学生对象
// Student student= (Student)session.getAttribute("student");
// // 从会话中获取管理员对象
// Admin admin= (Admin)session.getAttribute("admin");
// // 从会话中获取教师对象
// Teacher teacher= (Teacher)session.getAttribute("teacher");
// // 如果会话中存在学生对象,且不存在管理员对象和教师对象,则跳转到学生列表页面
// if (student != null && admin == null && teacher == null) {
// request.getRequestDispatcher("/WEB-INF/student/studentList.jsp").forward(request, response);
// // 如果会话中存在管理员对象,且不存在学生对象和教师对象,则跳转到管理员查找学生列表页面
// } else if (admin != null && student == null && teacher == null) {
// request.getRequestDispatcher("/WEB-INF/admin/aFindStudentList.jsp").forward(request, response);
// // 如果会话中存在教师对象,且不存在学生对象和管理员对象,则跳转到教师查找学生列表页面
// } else if (teacher != null && admin == null && student == null) {
// request.getRequestDispatcher("/WEB-INF/teacher/tFindStudentList.jsp").forward(request, response);
// // 如果会话中不存在学生对象、管理员对象和教师对象,则跳转到错误页面
// } else {
// request.getRequestDispatcher("error.jsp").forward(request, response);
// }
// }
// // HttpSession session = request.getSession();
// // Student student= (Student)session.getAttribute("student");
// // Admin admin= (Admin)session.getAttribute("admin");
// // Teacher teacher= (Teacher)session.getAttribute("teacher");
// // if (student != null && admin == null && teacher == null) {
// // request.getRequestDispatcher("/WEB-INF/student/studentList.jsp").forward(request, response);
// // } else if (admin != null && student == null && teacher == null) {
// // request.getRequestDispatcher("/WEB-INF/admin/aFindStudentList.jsp").forward(request, response);
// // } else if (teacher != null && admin == null && student == null) {
// // request.getRequestDispatcher("/WEB-INF/teacher/tFindStudentList.jsp").forward(request, response);
// // } else {
// // request.getRequestDispatcher("error.jsp").forward(request, response);
// // }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// this.doPost(request,response);
// }
//}

@ -18,15 +18,10 @@ import java.util.List;
@WebServlet("/studentOptionalCourseServlet")
public class StudentOptionalCourseServlet extends HttpServlet {
// 处理POST请求
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求编码为utf-8
request.setCharacterEncoding("utf-8");
// 获取当前会话
HttpSession session = request.getSession();
// 从会话中获取学生对象
Student student= (Student)session.getAttribute("student");
// 从会话中获取管理员对象
Admin admin =(Admin)session.getAttribute("admin");
//调用StudentService完成查询
@ -36,13 +31,10 @@ public class StudentOptionalCourseServlet extends HttpServlet {
request.setAttribute("optionalcourses",optionalcourses);
//转发到list.jsp
// 如果student不为空且admin为空则跳转到studentOptionalCourse.jsp页面
if (student != null && admin == null) {
request.getRequestDispatcher("/WEB-INF/student/studentOptionalCourse.jsp").forward(request,response);
// 如果admin不为空且student为空则跳转到allStudentOptionalCourse.jsp页面
} else if (admin != null && student == null) {
request.getRequestDispatcher("/WEB-INF/admin/allStudentOptionalCourse.jsp").forward(request, response);
// 否则跳转到error.jsp页面
} else {
request.getRequestDispatcher("error.jsp").forward(request, response);
}
@ -53,65 +45,3 @@ public class StudentOptionalCourseServlet extends HttpServlet {
this.doPost(request,response);
}
}
//package web.servlet.student;
//
//import domain.Admin;
//import domain.Course;
//import domain.SelectCourse;
//import domain.Student;
//import service.StudentService;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//import java.util.List;
//
//@WebServlet("/studentOptionalCourseServlet")
//public class StudentOptionalCourseServlet extends HttpServlet {
// // 处理POST请求
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求编码为utf-8
// request.setCharacterEncoding("utf-8");
// // 获取当前会话
// HttpSession session = request.getSession();
// // 从会话中获取学生对象
// Student student= (Student)session.getAttribute("student");
// // 从会话中获取管理员对象
// Admin admin =(Admin)session.getAttribute("admin");
//
// //调用StudentService完成查询-
// StudentService studentService = new StudentServiceImpl();
// List<Course> optionalcourses = studentService.findAllOptionalCourse();
// //将list存入request域-
// request.setAttribute("optionalcourses",optionalcourses);
// //转发到list.jsp-
//
// // 如果student不为空且admin为空则跳转到studentOptionalCourse.jsp页面
// if (student != null && admin == null) {
// request.getRequestDispatcher("/WEB-INF/student/studentOptionalCourse.jsp").forward(request,response);
// // 如果admin不为空且student为空则跳转到allStudentOptionalCourse.jsp页面
// } else if (admin != null && student == null) {
// request.getRequestDispatcher("/WEB-INF/admin/allStudentOptionalCourse.jsp").forward(request, response);
// // 否则跳转到error.jsp页面
// } else {
// request.getRequestDispatcher("error.jsp").forward(request, response);
// }
// //if (student != null && admin == null) {
// // request.getRequestDispatcher("/WEB-INF/student/studentOptionalCourse.jsp").forward(request,response);
// // } else if (admin != null && student == null) {
// // request.getRequestDispatcher("/WEB-INF/admin/allStudentOptionalCourse.jsp").forward(request, response);
// // } else {
// // request.getRequestDispatcher("error.jsp").forward(request, response);
// // }
//
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// this.doPost(request,response);
// }
//}

@ -16,53 +16,30 @@ import java.util.Date;
@WebServlet("/studentPasswordUpdateServlet")
public class StudentPasswordUpdateServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
<<<<<<< HEAD
=======
// 设置请求的字符编码为UTF-8以支持中文
// 设置请求的字符编码为utf-8
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
request.setCharacterEncoding("utf-8");
// 获取当前会话
HttpSession session = request.getSession();
// 从会话中获取学生对象
Student student= (Student)session.getAttribute("student");
// 获取学生id
String studentid = student.getS_id();
// 获取新密码
String newpassword = request.getParameter("student-newpassword");
// 获取确认新密码
String ennewpassword = request.getParameter("student-ennewpassword");
// 定义正则表达式匹配3-12位字母、数字、下划线
String regex = "^[\\w]{3,12}$";
// 判断新密码是否符合正则表达式
// 判断新密码是否符合正则表达式
boolean flag = newpassword.matches(regex);
// 如果不符合,则设置错误信息,并跳转到修改密码页面
if (!flag) {
request.setAttribute("update_msg", "密码格式错误,重新提交!"+String.format("%tT",new Date()));
request.getRequestDispatcher("/WEB-INF/student/studentUpdatePassword.jsp").forward(request, response);
// 如果新密码和确认密码不一致,则设置错误信息,并跳转到修改密码页面
} else if (!newpassword.equals(ennewpassword)) {
request.setAttribute("update_msg", "密码确认错误,请重新提交!" + String.format("%tT", new Date()));
request.getRequestDispatcher("/WEB-INF/student/studentUpdatePassword.jsp").forward(request, response);
// 如果新密码和确认密码一致,则调用服务层更新密码
} else {
StudentService service= new StudentServiceImpl();
service.updatePassword(studentid,newpassword);
// 根据学号查询学生信息
Student newStudent = service.findStudentById(student);
// 更新学生信息
student = newStudent;
// 将学生信息存入session
session.setAttribute("student",student);
// 设置成功信息,并跳转到修改密码页面
request.setAttribute("update_msg", "修改成功!" + String.format("%tT", new Date()));
request.getRequestDispatcher("/WEB-INF/student/studentUpdatePassword.jsp").forward(request, response);
}
@ -73,103 +50,3 @@ public class StudentPasswordUpdateServlet extends HttpServlet {
doPost(request,response);
}
}
//package web.servlet.student;
//
//import domain.Student;
//import service.StudentService;
//import service.impl.StudentServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//import java.util.Date;
//
//@WebServlet("/studentPasswordUpdateServlet")
//// 学生密码更新Servlet
//public class StudentPasswordUpdateServlet extends HttpServlet {
// // 处理POST请求
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求的字符编码为UTF-8以支持中文
// // 设置请求的字符编码为utf-8
// request.setCharacterEncoding("utf-8");
// // 获取当前会话
// HttpSession session = request.getSession();
// // 从会话中获取学生对象
// Student student= (Student)session.getAttribute("student");
//
// // 获取学生id
// String studentid = student.getS_id();
// // 获取新密码
// String newpassword = request.getParameter("student-newpassword");
// // 获取确认新密码
// String ennewpassword = request.getParameter("student-ennewpassword");
// // 定义正则表达式匹配3-12位字母、数字、下划线
// String regex = "^[\\w]{3,12}$";
// // 判断新密码是否符合正则表达式
// // 判断新密码是否符合正则表达式
// boolean flag = newpassword.matches(regex);
// // 如果不符合,则设置错误信息,并跳转到修改密码页面
// if (!flag) {
// request.setAttribute("update_msg", "密码格式错误,重新提交!"+String.format("%tT",new Date()));
// request.getRequestDispatcher("/WEB-INF/student/studentUpdatePassword.jsp").forward(request, response);
// // 如果新密码和确认密码不一致,则设置错误信息,并跳转到修改密码页面
// } else if (!newpassword.equals(ennewpassword)) {
// request.setAttribute("update_msg", "密码确认错误,请重新提交!" + String.format("%tT", new Date()));
// request.getRequestDispatcher("/WEB-INF/student/studentUpdatePassword.jsp").forward(request, response);
// // 如果新密码和确认密码一致,则调用服务层更新密码
// } else {
//
// StudentService service= new StudentServiceImpl();
// service.updatePassword(studentid,newpassword);
//
// // 根据学号查询学生信息
// Student newStudent = service.findStudentById(student);
// // 更新学生信息
// student = newStudent;
// // 将学生信息存入session
// session.setAttribute("student",student);
//
// // 设置成功信息,并跳转到修改密码页面
// request.setAttribute("update_msg", "修改成功!" + String.format("%tT", new Date()));
// request.getRequestDispatcher("/WEB-INF/student/studentUpdatePassword.jsp").forward(request, response);
// }
//
// }
// // request.setCharacterEncoding("utf-8");
// // HttpSession session = request.getSession();
// // Student student= (Student)session.getAttribute("student");
// //
// // String studentid = student.getS_id();
// // String newpassword = request.getParameter("student-newpassword");
// // String ennewpassword = request.getParameter("student-ennewpassword");
// // String regex = "^[\\w]{3,12}$";
// // boolean flag = newpassword.matches(regex);
// // if (!flag) {
// // request.setAttribute("update_msg", "密码格式错误,重新提交!"+String.format("%tT",new Date()));
// // request.getRequestDispatcher("/WEB-INF/student/studentUpdatePassword.jsp").forward(request, response);
// // } else if (!newpassword.equals(ennewpassword)) {
// // request.setAttribute("update_msg", "密码确认错误,请重新提交!" + String.format("%tT", new Date()));
// // request.getRequestDispatcher("/WEB-INF/student/studentUpdatePassword.jsp").forward(request, response);
// // } else {
// //
// // StudentService service= new StudentServiceImpl();
// // service.updatePassword(studentid,newpassword);
// //
// // Student newStudent = service.findStudentById(student);
// // student = newStudent;
// // session.setAttribute("student",student);
// //
// // request.setAttribute("update_msg", "修改成功!" + String.format("%tT", new Date()));
// // request.getRequestDispatcher("/WEB-INF/student/studentUpdatePassword.jsp").forward(request, response);
// // }
// //
// // }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -18,16 +18,11 @@ import java.util.List;
@WebServlet("/studentSelectCourseListServlet")
public class StudentSelectCourseListServlet extends HttpServlet {
// 处理POST请求
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求编码为utf-8
request.setCharacterEncoding("utf-8");
// 获取当前会话
HttpSession session = request.getSession();
// 从会话中获取学生对象
Student student= (Student)session.getAttribute("student");
// 从会话中获取管理员对象
Admin admin =(Admin)session.getAttribute("admin");
//调用StudentService完成查询
@ -36,23 +31,13 @@ public class StudentSelectCourseListServlet extends HttpServlet {
List<SelectCourse> selectcourses = studentService.findAllSelectCourse(student.getS_id());
//将list存入request域
request.setAttribute("selectcourses",selectcourses);
<<<<<<< HEAD
//转发到list.jsp
=======
//转发到list.jsp-
// 如果学生不为空,则跳转到学生选课列表页面
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
request.getRequestDispatcher("/WEB-INF/student/studentSelectCourseList.jsp").forward(request,response);
} else if (admin != null && student == null) {
// 如果管理员不为空,学生为空,则查询所有学生的选课列表,并跳转到管理员查看所有学生选课列表页面
List<SelectCourse> selectcourses = studentService.findSelectCourseAllStudent();
request.setAttribute("selectcourses", selectcourses);
request.getRequestDispatcher("/WEB-INF/admin/allStudentSelectCourseList.jsp").forward(request, response);
} else {
// 否则,跳转到错误页面
request.getRequestDispatcher("error.jsp").forward(request, response);
}

@ -28,24 +28,15 @@ public class AddOptionalCourseServlet extends HttpServlet {
CourseService service = new CourseServiceImpl();
Course course = service.findSelectCourseByCourseId(cid);
// 判断课程是否为空
if (course != null) {
// 设置请求属性提示课程ID冲突
request.setAttribute("update_msg","课程ID冲突请重新添加"+String.format("%tT",new Date()));
// 转发到添加可选课程页面
request.getRequestDispatcher("/WEB-INF/teacher/addOptionalCourse.jsp").forward(request,response);
}else {
// 创建新的课程对象
Course newCourse = new Course();
// 设置课程ID
newCourse.setC_id(cid);
// 设置课程名称
newCourse.setC_name(cname);
// 设置课程信息
newCourse.setC_info(cinfo);
// 设置教师ID
newCourse.setT_id(teacher.getT_id());
// 设置教师名称
newCourse.setT_name(teacher.getT_name());
service.addOptionalCourse(newCourse);

@ -26,26 +26,17 @@ public class TeacherListServlet extends HttpServlet {
//将list存入request域
request.setAttribute("teachers",teachers);
// 设置请求的字符编码为utf-8
request.setCharacterEncoding("utf-8");
// 获取当前会话
HttpSession session = request.getSession();
// 从会话中获取学生对象
Student student= (Student)session.getAttribute("student");
// 从会话中获取管理员对象
Admin admin= (Admin)session.getAttribute("admin");
// 从会话中获取教师对象
Teacher teacher= (Teacher)session.getAttribute("teacher");
// 如果会话中存在学生对象,且不存在管理员对象和教师对象,则跳转到学生查找教师列表页面
if (student != null && admin == null && teacher == null) {
request.getRequestDispatcher("/WEB-INF/student/sFindTeacherList.jsp").forward(request, response);
// 如果会话中存在管理员对象,且不存在学生对象和教师对象,则跳转到管理员查找教师列表页面
} else if (admin != null && student == null && teacher == null) {
request.getRequestDispatcher("/WEB-INF/admin/aFindTeacherList.jsp").forward(request, response);
// 如果会话中存在教师对象,且不存在学生对象和管理员对象,则跳转到教师查找教师列表页面
} else if (teacher != null && admin == null && student == null) {
request.getRequestDispatcher("/WEB-INF/teacher/tFindTeacherList.jsp").forward(request, response);
// 如果会话中不存在学生对象、管理员对象和教师对象,则跳转到错误页面
} else {
request.getRequestDispatcher("error.jsp").forward(request, response);
}

@ -19,15 +19,10 @@ import java.util.List;
@WebServlet("/teacherOptionalCourseServlet")
public class TeacherOptionalCourseServlet extends HttpServlet {
// 处理POST请求
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求编码为utf-8
request.setCharacterEncoding("utf-8");
// 获取当前会话
HttpSession session = request.getSession();
// 从会话中获取教师对象
Teacher t = (Teacher) session.getAttribute("teacher");
// 如果教师对象不为空
if (t != null) {
//调用StudentService完成查询
TeacherService service = new TeacherServiceImpl();

@ -19,60 +19,31 @@ import java.util.Date;
@WebServlet("/teacherPasswordUpdateServlet")
public class TeacherPasswordUpdateServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求编码为utf-8
request.setCharacterEncoding("utf-8");
// 获取当前会话
HttpSession session = request.getSession();
// 从会话中获取教师对象
Teacher teacher = (Teacher)session.getAttribute("teacher");
// 获取教师ID
String teacherid = teacher.getT_id();
<<<<<<< HEAD
=======
//3
// 获取新密码
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
String newpassword = request.getParameter("teacher-newpassword");
// 获取确认新密码
String ennewpassword = request.getParameter("teacher-ennewpassword");
// 定义密码格式正则表达式
String regex = "^[\\w]{3,12}$";
// 判断新密码是否符合格式
boolean flag = newpassword.matches(regex);
// 如果新密码不符合格式
if (!flag) {
// 设置错误信息
request.setAttribute("update_msg", "密码格式错误,重新提交!"+String.format("%tT",new Date()));
// 转发到修改密码页面
request.getRequestDispatcher("/WEB-INF/teacher/teacherUpdatePassword.jsp").forward(request, response);
// 如果新密码和确认新密码不一致
} else if (!newpassword.equals(ennewpassword)) {
// 设置错误信息
request.setAttribute("update_msg", "密码确认错误,请重新提交!" + String.format("%tT", new Date()));
// 转发到修改密码页面
request.getRequestDispatcher("/WEB-INF/teacher/teacherUpdatePassword.jsp").forward(request, response);
// 如果新密码和确认新密码一致
} else {
// 创建TeacherService对象
TeacherService service= new TeacherServiceImpl();
// 调用updatePassword方法更新密码
service.updatePassword(teacherid,newpassword);
// 根据teacherid查找新的Teacher对象
Teacher newTeacher = service.findTeacherById(teacher);
// 将新的Teacher对象赋值给teacher
teacher = newTeacher;
// 将teacher对象存入session中
session.setAttribute("teacher",teacher);
// 设置update_msg属性提示修改成功
request.setAttribute("update_msg", "修改成功!" + String.format("%tT", new Date()));
// 转发到teacherUpdatePassword.jsp页面
request.getRequestDispatcher("/WEB-INF/teacher/teacherUpdatePassword.jsp").forward(request, response);
}

@ -23,42 +23,28 @@ import java.util.Date;
@WebServlet("/updateOptionalCourseScoreServlet")
public class UpdateOptionalCourseScoreServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求编码为utf-8
request.setCharacterEncoding("utf-8");
// 获取请求参数
String cid = request.getParameter("cid");
String sid = request.getParameter("sid");
String sScore = request.getParameter("student-score");
// 创建学生服务对象
StudentService service = new StudentServiceImpl();
// 创建课程服务对象
CourseService service1 = new CourseServiceImpl();
// 创建选课服务对象
SelectCourseService service2 = new SelectCourseServiceImpl();
// 根据课程id和学生id更新学生成绩
service2.upDateScoreByCidAndSid(cid,sid,sScore);
//创建一个Student对象
Student student = new Student();
//设置Student对象的id
student.setS_id(sid);
//根据Student对象的id查找学生信息
Student s = service.findStudentById(student);
//根据课程id查找选课信息
Course c = service1.findSelectCourseByCourseId(cid);
//根据课程id和学生id查找成绩信息
SelectCourse sc = service2.findScoreByCourseIdAndStudentId(cid,sid);
//将学生信息、选课信息和成绩信息存入request对象中
request.setAttribute("s",s);
request.setAttribute("c",c);
request.setAttribute("sc",sc);
//设置修改分数成功的提示信息
request.setAttribute("update_msg","修改分数成功!"+String.format("%tT",new Date()));
//转发到updateOptionalCourseScore.jsp页面
request.getRequestDispatcher("/WEB-INF/teacher/updateOptionalCourseScore.jsp").forward(request,response);
}

@ -20,45 +20,24 @@ import java.io.IOException;
@WebServlet("/updateScoreServlet")
public class UpdateScoreServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
<<<<<<< HEAD
=======
//中文
// 设置请求的字符编码为utf-8
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
request.setCharacterEncoding("utf-8");
// 获取请求参数cid
String cid = request.getParameter("cid");
// 获取请求参数sid
String sid = request.getParameter("sid");
// 创建StudentService对象
StudentService service = new StudentServiceImpl();
// 创建Student对象
Student student = new Student();
// 设置Student对象的s_id属性
student.setS_id(sid);
// 根据Student对象的s_id属性查找学生信息
// 根据学生id查找学生信息
Student s = service.findStudentById(student);
// 创建CourseServiceImpl对象
CourseService service1 = new CourseServiceImpl();
// 根据课程id查找选课信息
Course c = service1.findSelectCourseByCourseId(cid);
// 创建SelectCourseServiceImpl对象
SelectCourseService service2 = new SelectCourseServiceImpl();
// 根据课程id和学生id查找成绩信息
SelectCourse sc = service2.findScoreByCourseIdAndStudentId(cid,sid);
// 将学生信息、选课信息和成绩信息存入request对象中
request.setAttribute("s",s);
request.setAttribute("c",c);
request.setAttribute("sc",sc);
// 转发到updateOptionalCourseScore.jsp页面
request.getRequestDispatcher("/WEB-INF/teacher/updateOptionalCourseScore.jsp").forward(request,response);
}

@ -16,36 +16,19 @@ import java.util.Date;
@WebServlet("/updateTeacherInfoServlet")
public class UpdateTeacherInfoServlet extends HttpServlet {
// 处理POST请求
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求编码为utf-8
request.setCharacterEncoding("utf-8");
// 获取教师ID
String tid = request.getParameter("teacher-id");
// 获取教师姓名
String name = request.getParameter("teacher-name");
// 获取教师性别
String sex = request.getParameter("teacher-sex");
// 获取教师学历
String education = request.getParameter("teacher-education");
// 获取教师职称
String title = request.getParameter("teacher-title");
Teacher updateTeacher = new Teacher();
<<<<<<< HEAD
//判断输入位数是否大于数据库位数
=======
//判断输入位数是否大于数据库位数-
//判断输入的姓名、学历、职称是否合法
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
if (name.length() > 4 || education.length() > 20 || title.length()>24 || name.contains("<") || education.contains("<") || title.contains("<")) {
//将错误信息存入request对象中
request.setAttribute("update_msg","格式错误,请重新提交!"+String.format("%tT",new Date()));
//转发到updateTeacherServlet页面
request.getRequestDispatcher("updateTeacherServlet?tid="+tid).forward(request, response);
}else {
//封装教师对象

@ -17,27 +17,13 @@ import java.util.List;
public class UpdateTeacherOptionalCourseServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
<<<<<<< HEAD
// HttpSession session = request.getSession();
=======
// HttpSession session = request.getSession();-
// 获取请求参数中的课程ID
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
String cid = (String)request.getParameter("cid");
// 创建TeacherService对象
TeacherService service = new TeacherServiceImpl();
// 根据课程ID查找可选课程
Course c = service.findOptionalCourseByCourseId(cid);
// 将课程对象存入请求属性中
request.setAttribute("course",c);
// 输出课程ID
System.out.println(c.getC_id());
// 输出课程名称
System.out.println(c.getC_name());
// 输出课程信息
System.out.println(c.getC_info());
request.getRequestDispatcher("/WEB-INF/teacher/updateTeacherOptionalCourseInfo.jsp").forward(request,response);

@ -22,24 +22,15 @@ import java.util.List;
@WebServlet("/updateTeacherServlet")
public class UpdateTeacherServlet extends HttpServlet {
// 处理POST请求
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求编码为utf-8
request.setCharacterEncoding("utf-8");
// 获取当前会话
HttpSession session = request.getSession();
// 获取请求参数中的教师id
String teacherid = request.getParameter("tid");
// 创建教师对象
Teacher teacher = new Teacher();
// 设置教师id
teacher.setT_id(teacherid);
// 创建教师服务对象
TeacherService service = new TeacherServiceImpl();
// 根据教师id查找教师信息
Teacher newTeacher = service.findTeacherById(teacher);
// 将教师信息存入请求属性中
request.setAttribute("teacher",newTeacher);
CDCService service2 = new CDCServiceImpl();
@ -47,7 +38,6 @@ public class UpdateTeacherServlet extends HttpServlet {
List<CDC> departmentList = service2.findAllDepartment();
List<CDC> classList = service2.findAllClass();
//将collegeList、departmentList、classList放入session中
session.setAttribute("collegeLists",collegeList);
session.setAttribute("departmentLists",departmentList);
session.setAttribute("classLists",classList);

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<<<<<<< HEAD
<<<<<<< HEAD
=======
=======
>>>>>>> remotes/origin/develop
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/web" relative="/" />
</webroots>
</configuration>
</facet>
</component>
<<<<<<< HEAD
>>>>>>> remotes/origin/develop
=======
>>>>>>> remotes/origin/develop
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
</component>
</module>

@ -1,198 +1,54 @@
/*
.progress
*/
.progress {
/*
2使
*/
margin-top: 2px;
/*
200
*/
.progress{
margin-top:2px;
width: 200px;
/*
14
*/
height: 14px;
/*
10
*/
margin-bottom: 10px;
/*
*/
overflow: hidden;
/*
#f5f5f5
*/
background-color: #f5f5f5;
/*
4使
*/
border-radius: 4px;
/*
WebKitChromeSafari
inset0 1px 2px12rgba(0,0,0,.1)0.1
*/
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0,.1);
/*
-webkit-box-shadowCSSWebKit
*/
box-shadow: inset 0 1px 2px rgba(0, 0, 0,.1);
-webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
}
/*
.progress-bar
*/
.progress-bar {
/*
rgb(92, 184, 92)绿使
*/
.progress-bar{
background-color: rgb(92, 184, 92);
/*
使线使
linear-gradient线45deg45
rgba(255, 255, 255, 0.14902) 25%, transparent 25%25%使25%
*/
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.14902) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.14902) 50%, rgba(255, 255, 255, 0.14902) 75%, transparent 75%, transparent);
/*
线40px 40px40
*/
background-size: 40px 40px;
/*
使
rgba(0, 0, 0, 0.14902)0px -1px 0px 0px1px0px0pxinset线
*/
box-shadow: rgba(0, 0, 0, 0.14902) 0px -1px 0px 0px inset;
/*
border-boxborderpadding便
*/
box-sizing: border-box;
/*
rgb(255, 255, 255)使
*/
color: rgb(255, 255, 255);
/*
使
*/
display: block;
/*
使
*/
float: left;
/*
12
*/
font-size: 12px;
/*
20
*/
height: 20px;
line-height: 20px;
/*
使
*/
text-align: center;
/*
0
*/
transition-delay: 0s;
/*
0.6
*/
transition-duration: 0.6s;
/*
CSSwidth
*/
transition-property: width;
/*
ease使
*/
transition-timing-function: ease;
/*
266.188JavaScript
*/
width: 266.188px;
}
/*
.file
*/
.file {
/*
便toprightbottomleftinput
*/
position: relative;
/*
便
*/
display: inline-block;
/*
#337ab7
*/
background-color: #337ab7;
/*
4使
*/
border-radius: 4px;
/*
812便
*/
padding: 8px 12px;
/*
*/
overflow: hidden;
/*
#FFFFFF使
*/
color: #FFFFFF;
/*
线线使
*/
text-decoration: none;
/*
0
*/
text-indent: 0;
/*
20便
*/
line-height: 20px;
}
/*
.fileinput
*/
.file input {
/*
.filerighttop.file便
*/
position: absolute;
/*
100px使
*/
font-size: 100px;
/*
.fileright: 00top: 00
*/
right: 0;
top: 0;
/*
0使.file
*/
opacity: 0;
}
/*
.file
*/
.file:hover {
/*
.file#598FBE
*/
background: #598FBE;
/*
线
*/
text-decoration: none;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,19 +1,11 @@
/*
* @charset "utf-8";
* CSS使utf-8
*/
@charset "utf-8";
body {
background: url("../images/bg.jpg");
/* 设置页面背景图片的路径这里图片位于相对于当前CSS文件的images文件夹下文件名为bg.jpg */
background-position: center;
/* 让背景图片在水平和垂直方向都居中显示 */
background-size: cover;
/* 使背景图片自适应铺满整个页面可视区域,可能会根据页面尺寸拉伸或缩放图片以完全覆盖 */
padding-bottom: 0px;
/* 将body元素底部的内边距设置为0像素控制页面底部空白区域大小等布局效果 */
}
.layadmin-user-login-icon {
position: absolute;
left: 1px;
@ -22,22 +14,7 @@ body {
line-height: 36px;
text-align: center;
color: #d2d2d2;
/*
*
* position: absolute; html
* left: 1px; 1
* top: 1px; 1
* width: 38px; 38
* line-height: 36px; 36
* text-align: center;
* color: #d2d2d2;
*/
}
.login-main.layui-input {
.login-main .layui-input {
padding-left: 38px;
/*
* login-mainlayui-input38
*
*/
}

@ -1,10 +1,6 @@
/*
* @charset "utf-8";
* CSS使utf-8
*/
@charset "utf-8";
/* 针对layui布局下的自定义头部样式 */
.layui-layout-admin.my-header {
.layui-layout-admin .my-header {
position: fixed;
top: 0;
left: 0;
@ -12,19 +8,9 @@
height: 60px;
background: #393D49;
z-index: 2;
/*
* position: fixed; 使
* top: 0; 0
* left: 0; 0
* width: 100%;
* height: 60px; 60
* background: #393D49;
* z-index: 2;
*/
}
/* layui布局下头部中自定义的logo样式 */
.layui-layout-admin.my-header.my-header-logo {
}
.layui-layout-admin .my-header .my-header-logo {
display: inline-block;
width: auto;
height: 30px;
@ -33,60 +19,31 @@
line-height: 30px;
padding: 15px;
vertical-align: top;
/*
* display: inline-block;
* width: auto;
* height: 30px; 30
* color: white;
* font-size: 18px; 18
* line-height: 30px; 使
* padding: 15px;
* vertical-align: top;
*/
}
/* layui布局下头部中作为图片的logo样式 */
.layui-layout-admin.my-header img.my-header-logo {
}
.layui-layout-admin .my-header img.my-header-logo {
width: 150px;
height: 40px;
text-align: center;
line-height: 40px;
padding: 10px;
border: none;
/*
* my-header-logo
* width: 150px; 150
* height: 40px; 40
* text-align: center;
* line-height: 40px; 使
* padding: 10px;
* border: none;
*/
}
/* 以下是名为my-header-btn的类选择器样式可能用于头部的按钮相关元素 */
}
/* index */
.my-header-btn {
display: inline-block;
width: auto;
height: 100%;
line-height: 60px;
/*
* display: inline-block; 便
* width: auto;
* height: 100%;
* line-height: 60px; 便使
*/
}
.my-header-btn.layui-btn.layui-icon {
.my-header-btn .layui-btn .layui-icon {
margin-right: 0;
/* 针对同时具有layui-btn和layui-icon类的元素可能是layui框架中的按钮图标元素将其右侧外边距设置为0调整图标与其他元素的间距 */
}
.my-header-user-nav {
float: right;
/* 让该元素(可能是包含用户相关操作的导航元素)向右浮动,使其在头部靠右排列,常用于页面头部的用户信息、操作按钮等布局 */
}
.my-header-user-nav img {
@ -96,40 +53,22 @@
line-height: 40px;
border: none;
border-radius: 5px;
/*
*
* width: 40px; 40
* height: 40px; 40使
* text-align: center;
* line-height: 40px;
* border: none;
* border-radius: 5px; 使
*/
}
.my-header-user-nav.layui-nav-item a.name {
padding-left: 5px!important;
/* 针对用户导航中类名为layui-nav-item下的a元素且类名为name的元素可能是显示用户名之类的文本元素强制设置左侧内边距为5像素调整文本与其他元素的间距 */
.my-header-user-nav .layui-nav-item a.name {
padding-left: 5px !important;
}
.my-header ul.layui-nav {
display: inline-block;
vertical-align: top;
border-radius: 0;
/*
* layui-navul
* display: inline-block; 便
* vertical-align: top;
* border-radius: 0; 使
*/
}
.my-header ul.layui-nav li a {
max-height: 60px;
/* 限制头部导航列表中每个列表项li内链接a元素的最大高度为60像素可能是为了保证整体头部布局的一致性和美观性 */
}
/* 侧边栏样式 */
.my-side {
position: fixed;
top: 60px;
@ -137,35 +76,21 @@
width: 200px;
z-index: 2;
overflow-x: hidden;
/*
* position: fixed; 使
* top: 60px; 60
* bottom: 0; 0使
* width: 200px; 200
* z-index: 2;
* overflow-x: hidden;
*/
}
.my-side.layui-nav {
.my-side .layui-nav {
border-radius: 0;
min-height: 100%;
/*
* layui-nav100%使
*/
}
.my-side ul.layui-nav li a i,.layui-nav.layui-nav-child a i,.layui-nav.layui-nav-item a i,.layui-tab-card >.layui-tab-title li span i {
.my-side ul.layui-nav li a i, .layui-nav .layui-nav-child a i, .layui-nav .layui-nav-item a i, .layui-tab-card > .layui-tab-title li span i {
margin-right: 5px;
/* 对侧边栏导航、子导航、普通导航项以及选项卡标题中的图标元素i标签统一设置右侧外边距为5像素调整图标与文本的间距使布局更美观 */
}
.my-side ul.layui-nav li dl dd a i {
margin-left: 15px;
/* 针对侧边栏导航中dl列表下dd元素内的图标元素i标签设置左侧外边距为15像素调整图标在这些特定元素内的位置布局 */
}
/* 页面主体内容区域样式 */
.my-body {
position: fixed;
top: 60px;
@ -174,20 +99,10 @@
right: 0;
z-index: 1;
overflow: hidden;
/*
* position: fixed; 使
* top: 60px; 60
* bottom: 0;
* left: 200px; 200
* right: 0;
* z-index: 1;
* overflow: hidden;
*/
}
.body {
padding: 10px;
/* 给类名为body的元素设置内边距为10像素在元素内部四周增加一定空间方便内容排版避免内容紧贴边界 */
}
.frame-main {
@ -197,30 +112,19 @@
height: 433px;
background-color: #edededbf;
backdrop-filter: blur(20px);
/*
* margin-top: -210px; top: 50%使
* top: 50%;
* position: relative; 便
* height: 433px; 433
* background-color: #edededbf; rgba
* backdrop-filter: blur(20px); 20
*/
}
.my-body.layui-tab,.my-body.layui-tab.layui-tab-content {
.my-body .layui-tab, .my-body .layui-tab .layui-tab-content {
margin: 0;
padding: 0;
/* 去除主体内容区域内选项卡layui-tab及其内容区域layui-tab-content的默认外边距和内边距方便进行自定义的布局和样式调整 */
}
.my-body.layui-tab.layui-tab-title li:first-child > i {
.my-body .layui-tab .layui-tab-title li:first-child > i {
display: none;
/* 隐藏主体内容区域内选项卡标题layui-tab-title中第一个列表项li内的图标元素i标签可能是根据设计需求对首个选项卡的图标进行特殊处理 */
}
.my-body.layui-tab,.my-body.layui-tab.layui-tab-content,.my-body.layui-tab.layui-tab-item {
.my-body .layui-tab, .my-body .layui-tab .layui-tab-content, .my-body .layui-tab .layui-tab-item {
height: 100%;
/* 让主体内容区域内的选项卡、选项卡内容以及每个选项卡对应的具体内容项layui-tab-item都占满所在父元素的垂直空间保证内容完整显示且布局合理 */
}
.my-body iframe {
@ -228,94 +132,447 @@
height: 100%;
border: none;
outline: none;
/*
* iframe100%使线使
*/
}
/* 页面底部样式 */
.layui-layout-admin.my-footer {
.layui-layout-admin .my-footer {
height: 40px;
padding: 2px 0;
/* 设置底部元素的高度为40像素并在垂直方向上添加2像素的内边距上下内边距用于放置底部相关的版权信息、提示文字等内容 */
}
.layui-layout-admin.my-footer p {
.layui-layout-admin .my-footer p {
height: 20px;
line-height: 20px;
font-size: 12px;
text-align: center;
/*
* p
* height: 20px; 20
* line-height: 20px; 使
* font-size: 12px; 12
* text-align: center; 使
*/
}
.my-btn-box {
height: 38px;
margin-bottom: 10px;
/* 定义一个类名为my-btn-box的元素样式设置高度为38像素并在底部添加10像素的外边距可能用于按钮组等元素的整体样式控制方便布局和外观调整 */
}
.my-pay-box > div p {
text-align: center;
margin-bottom: 10px;
/* 针对类名为my-pay-box下的div元素内的p元素设置文本水平居中对齐并在底部添加10像素的外边距常用于支付相关信息、提示等文本的排版布局 */
}
/* welcome页面相关样式 */
/* welcome */
.my-index-main button.layui-icon {
width: 100%;
font-size: 20px;
/* 针对类名为my-index-main下的button元素且具有layui-icon类可能是layui框架中的图标按钮元素设置宽度为100%占满父元素宽度字号为20像素用于调整按钮图标大小和外观显示效果 */
}
.my-index-main.my-nav-btn {
.my-index-main .my-nav-btn {
background: #efefef;
cursor: pointer;
border-radius: 2px;
overflow: hidden;
/*
* my-index-mainmy-nav-btn
* background: #efefef;
* cursor: pointer;
* border-radius: 2px; 2使
* overflow: hidden;
*/
}
.my-index-main.my-nav-text:first-child {
.my-index-main .my-nav-text:first-child {
height: 24px;
line-height: 25px;
font-size: 16px;
font-weight: bold;
/* my-index-mainmy-nav-text
* height: 24px; 24
* line-height: 25px; 使
* font-size: 16px; 16
* font-weight: bold;
*/
}
.my-index-main.my-nav-text:last-child {
.my-index-main .my-nav-text:last-child {
height: 20px;
line-height: 20px;
font-size: 12px;
/* my-index-mainmy-nav-text
* height: 20px; 20
* line-height: 20px; 使
* font-size: 12px; 12
*/
}
/* 登录页面相关样式 */
/* login */
.login-box {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right:0;
}
right: 0;
margin: auto;
width: 320px;
height: 241px;
max-height: 300px;
}
.login-body .login-box h3 {
color: #444;
font-size: 22px;
font-weight: 100;
text-align: center;
}
.login-box .layui-input[type='number'] {
display: inline-block;
width: 50%;
vertical-align: top;
}
.login-box img {
display: inline-block;
width: 46%;
height: 38px;
border: none;
vertical-align: top;
cursor: pointer;
margin-left: 4%;
}
.login-box button.btn-reset {
width: 95px;
}
.login-box button.btn-submit {
width: 190px;
}
.login-main {
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 350px;
margin: 0 auto;
}
.login-main header {
height: 35px;
line-height: 35px;
font-size: 30px;
font-weight: 100;
text-align: center;
padding-top: 58px;
}
.login-main header, .login-main form, .login-main form .layui-input-inline {
margin-bottom: 15px;
}
.login-main form .layui-input-inline, .login-main form .layui-input-inline input, .login-main form .layui-input-inline button {
width: 100%;
}
.login-main form .login-btn {
margin-bottom: 5px;
}
/* demo */
.site-demo-button div {
margin: 20px 30px 10px;
}
.site-demo-button .layui-btn {
margin: 0 7px 10px 0;
}
/* check */
input[type='checkbox'] {
vertical-align: middle;
}
.my-checkbox {
-webkit-appearance: none;
position: relative;
width: 20px;
height: 20px;
background-color: #FFFFFF;
border: solid 2px #28B779;
border-radius: 2px;
background-clip: padding-box;
display: inline-block;
cursor: pointer;
}
.my-checkbox:checked {
background-color: #28B779;
border: solid 0 #28B779;
}
.my-checkbox:checked:before {
position: absolute;
display: inline-block;
right: 50%;
bottom: 50%;
-webkit-transform: translate(50%, 50%);
-ms-transform: translate(50%, 50%);
transform: translate(50%, 50%);
font-family: "Microsoft Yahei";
content: "√";
color: #FFFFFF;
font-size: 16px;
font-weight: 600;
}
/* dblclick css */
.dblclick-tab tr td {
height: 30px;
line-height: 30px;
padding: 0 6px;
border-radius: 2px;
cursor: pointer;
}
.dblclick-tab tr td:hover {
color: black;
background: white;
}
.dblclick-tab tr td i {
position: relative;
top: 2px;
display: inline-block;
margin-right: 5px;
}
/* tips 404 */
.my-page-box {
font-family: "Segoe UI", "Lucida Grande", Helvetica, Arial, "Microsoft YaHei", FreeSans, Arimo, "Droid Sans", "wenquanyi micro hei", "Hiragino Sans GB", "Hiragino Sans GB W3", FontAwesome, sans-serif;
text-align: center;
padding: 20px;
background-color: white;
}
.my-page-box i {
font-size: 100px;
}
.my-page-box h2, .my-page-box h3, .my-page-box h4, .my-page-box h5 {
font-size: 80px;
}
.my-page-box p.msg {
color: #dce2ec;
font-size: 20px;
margin-top: 20px;
}
.my-page-box p.text {
color: #666;
font-size: 16px;
margin-top: 20px;
}
.my-page-box .my-btn-box {
margin-top: 20px;
margin-bottom: 20px;
}
/* tree table */
.my-tree-table-box .tree-table-tree-box {
width: 20%;
min-height: 200px;
display: inline-block;
vertical-align: top;
overflow-y: auto;
overflow-x: auto;
}
.my-tree-table-box .tree-table-table-box {
display: inline-block;
vertical-align: top;
width: 79%;
margin-left: 1%;
}
/* skin0 */
html .skin-0 .dblclick-tips-box .layui-layer-content {
background-color: #009688;
}
html .skin-0 .dblclick-tips-box i.layui-layer-TipsB {
border-right-color: #009688;
}
/* skin1 */
html .skin-1 .my-header .my-header-logo,
html .skin-1 .layui-nav .layui-nav-item a,
html .skin-1 .layui-nav .layui-nav-item a:hover {
color: #444;
}
html .skin-1 .my-header,
html .skin-1 .layui-nav,
html .skin-1 .layui-nav-child {
background: white;
}
html .skin-1 .layui-nav .layui-nav-item .layui-nav-child dd.layui-this a {
color: white;
}
html .skin-1 .layui-nav .layui-nav-item .layui-nav-child dd.layui-this,
html .skin-1 .layui-nav .layui-nav-item .layui-nav-child dd.layui-this > a,
html .skin-1 .layui-nav-tree .layui-nav-item > a:hover,
html .skin-1 .layui-nav .layui-nav-item .layui-nav-child dd:hover > a,
html .skin-1 .layui-tab-title li .layui-tab-close:hover,
html .skin-1 .dblclick-tips-box .layui-layer-content {
color: white !important;
background-color: #666 !important;
}
html .skin-1 .dblclick-tips-box i.layui-layer-TipsB {
border-right-color: #666;
}
html .skin-1 .layui-nav .layui-nav-itemed > a {
background: #444 !important;
}
html .skin-1 .layui-nav .layui-nav-more {
border-color: #444 transparent transparent;
}
html .skin-1 .layui-nav .layui-nav-mored {
border-color: transparent transparent #444;
}
/* skin2 */
html .skin-2 .my-header .my-header-logo,
html .skin-2 .layui-nav .layui-nav-item a,
html .skin-2 .layui-nav .layui-nav-item a:hover {
color: white;
}
html .skin-2 .my-header,
html .skin-2 .layui-nav,
html .skin-2 .layui-nav-child {
background-color: #01AAED;
}
html .skin-2 .layui-nav .layui-nav-item .layui-nav-child dd.layui-this a {
color: white;
}
html .skin-2 .layui-nav .layui-nav-item .layui-nav-child dd.layui-this,
html .skin-2 .layui-nav .layui-nav-item .layui-nav-child dd.layui-this > a,
html .skin-2 .layui-nav-tree .layui-nav-item > a:hover,
html .skin-2 .layui-nav .layui-nav-item .layui-nav-child dd:hover > a,
html .skin-2 .layui-tab-title li .layui-tab-close:hover,
html .skin-2 .dblclick-tips-box .layui-layer-content {
color: white !important;
background-color: #00C0F7 !important;
}
html .skin-2 .dblclick-tips-box i.layui-layer-TipsB {
border-right-color: #00C0F7;
}
html .skin-2 .layui-nav .layui-nav-itemed > a {
background-color: #1684af !important;
}
/* skin0-2 */
html .skin-2 .layui-nav .layui-nav-more,
html .skin-1 .layui-nav-tree .layui-nav-more,
html .skin-2 .layui-nav-tree .layui-nav-more {
border-color: white transparent transparent;
}
html .skin-2 .layui-nav .layui-nav-mored,
html .skin-1 .layui-nav-itemed .layui-nav-more,
html .skin-2 .layui-nav-itemed .layui-nav-more {
border-color: transparent transparent white;
}
/* tools */
.fl {
float: left;
}
.fr {
float: right;
}
.none {
display: none;
}
.block {
display: block;
}
.tc {
text-align: center;
}
.max-auto {
max-height: 450px;
overflow-y: auto;
}
/* layui css cover */
html body .layui-nav .layui-nav-bar {
opacity: 0 !important;
overflow: hidden !important;
}
.layui-nav .layui-this:after, .layui-nav-bar, .layui-nav-tree .layui-nav-itemed:after {
background-color: transparent;
}
.my-body .layui-tab-card > .layui-tab-title li {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.layui-layer-tips .layui-layer-content {
padding: 5px;
}
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
position: relative;
left: 12%;
top: -10px;
}
.tooltip .tooltiptext {
width: 138px;
background-color: #dad5d545;
color: #ff4545;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
}
.page-active-li {
background-color: #00FF00;
}
.page-li {
float: left;
border: 1px solid #e2e2e2;
display: inline-block;
vertical-align: middle;
padding: 0 15px;
height: 28px;
line-height: 28px;
margin: 0px 2px 5px -3px;
background-color: #fff;
color: #333;
font-size: 12px;
}
.page-li:hover {
color: #009688;
}
/* media */
@media screen and ( max-width: 450px) {
.my-header ul.my-header-user-nav li a.pay {
display: none;
}
}

@ -1,19 +1,11 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!-- 这是JSP页面的指令用于设置页面的内容类型为HTML字符编码为UTF-8并且指定使用的语言是Java -->
<html>
<head>
<!-- 设置页面的字符编码,不过这里的写法不太常规,<?php...?>这种语法一般是用在PHP中在这里可能是一种错误的混用正常在HTML中可以直接写固定值如<meta charset="UTF-8"> -->
<meta charset="<?php $this->options->charset();?>">
<!-- 指示浏览器以IE的最高版本或者Chrome 1的模式来渲染页面用于解决不同浏览器的兼容性问题 -->
<meta charset="<?php $this->options->charset(); ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<!-- 指示浏览器使用WebKit内核来渲染页面 -->
<meta name="renderer" content="webkit">
<!-- 设置视口相关属性规定页面宽度等于设备宽度初始缩放比例、最小缩放比例、最大缩放比例都为1.0,禁止用户手动缩放页面 -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- 指示浏览器不要对页面进行缓存转换,保持获取到的原始内容 -->
<meta http-equiv="Cache-Control" content="no-transform"/>
<!-- 定义页面的图标链接 -->
<link rel="icon" href="https://yoyling.com/favicon.ico">
<title>ERROR</title>
@ -21,20 +13,17 @@
body{
margin:0;padding:0;
font-family: PingFang SC,Microsoft YaHei,WenQuanYi Micro Hei,sans-serif;
/* 设置页面主体的外边距和内边距为0定义字体族优先使用苹方字体其次是微软雅黑、文泉驿微米黑等无衬线字体 */
}
a, button.submit {
color:#6E7173;
text-decoration:none;
-webkit-transition:all.1s ease-in;
-moz-transition:all.1s ease-in;
-o-transition:all.1s ease-in;
transition:all.1s ease-in;
/* 设置链接和特定按钮的文本颜色为灰色去除下划线并且定义了在不同浏览器下过渡效果的属性当元素状态改变时如鼠标悬停等会在0.1秒内平滑过渡样式变化 */
-webkit-transition:all .1s ease-in;
-moz-transition:all .1s ease-in;
-o-transition:all .1s ease-in;
transition:all .1s ease-in;
}
a:hover, a:active {
color:#6E7173;
/* 当鼠标悬停或者激活(比如点击按住时)链接元素时,保持文本颜色为灰色 */
}
.body404{
position: absolute;
@ -42,11 +31,9 @@
width: 100%;
background:#fff;
background-size: auto 100%;
/* 定义一个类名为body404的元素设置其绝对定位占满整个页面的高度和宽度背景颜色为白色背景图片尺寸自适应高度为100%(这里没看到背景图片相关设置,可能后续会添加或者有遗漏情况) */
}
.body-about.body404{
.body-about .body404{
background:#fff;
/* 当父元素有body-about类时其内部的body404元素背景颜色设置为白色可能用于特定页面布局区分样式 */
}
.site-name404 {
margin: 0 auto;
@ -60,25 +47,21 @@
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
-webkit-animation: hue 60s infinite linear;
/* 定义一个类名为site-name404的元素使其水平居中文本居中对齐设置字间距、字体大小、行高、字体粗细等样式属性文本颜色通过渐变背景和裁剪、填充等设置来实现渐变文字效果并且添加了一个名为hue的动画持续60秒无限循环线性播放 */
}
.site-name404 h1{
margin: 0 0 10px;
font-size:50px;
line-height:1.2;
/* 针对site-name404内部的h1元素设置外边距、字体大小和行高样式 */
}
.title404 span{
font-size: 15px;
width: 2px;
/* 设置类名为title404内部的span元素的字体大小和宽度样式 */
}
.title404 p{
font-size: 20px;
line-height:1.5;
margin:0;
color:#7b8993;
/* 设置类名为title404内部的p元素的字体大小、行高、外边距和文本颜色样式 */
}
.info404{
position: absolute;
@ -86,16 +69,13 @@
text-align: center;
width: 100%;
margin-top: -160px;
/* 定义一个类名为info404的元素绝对定位在页面垂直居中的位置通过top: 50%和负的外边距来实现精准居中),文本居中对齐,宽度占满整个页面 */
}
.body-about.info404{
.body-about .info404{
margin-top: -180px;
/* 当父元素有body-about类时其内部的info404元素调整上边距用于特定页面布局下的垂直位置微调 */
}
#footer404{
margin-top:30px;
font-size:10px;
/* 设置id为footer404的元素距离上方元素有30px的外边距字体大小为10px */
}
.index404 {
margin-top: 24px;
@ -118,11 +98,9 @@
border-radius: 25px;
background-color: #fff;
color: #7b8993;
/* 定义类名为index404的元素样式设置上边距、显示为行内块元素、禁止文本换行、鼠标指针变为手型、字间距、字体大小等诸多样式属性包括边框、行高、文本对齐、高度、内边距、圆角、背景颜色和文本颜色等用于呈现一个特定外观和交互效果的按钮样式 */
}
.icon-about{
padding: 10px 0 25px;
/* 定义类名为icon-about的元素的内边距样式用于布局调整 */
}
.icon-about a{
font-size: 20px;
@ -131,7 +109,6 @@
background-color: #000;
border-radius: 100%;
padding: 6px;
/* 定义类名为icon-about内部的链接元素样式设置字体大小、外边距、文本颜色、背景颜色、边框圆角和内边距用于呈现特定外观的图标样式可能是社交媒体图标之类的元素 */
}
@-webkit-keyframes hue {
from {
@ -141,27 +118,21 @@
to {
-webkit-filter: hue-rotate(-360deg);
}
/* 定义名为hue的动画关键帧从初始状态色相旋转0度到结束状态色相旋转-360度用于实现文本颜色渐变的动画效果 */
}
</style>
</head>
<body>
<div class="body404">
<div class="info404">
<header id="header404" class="clearfix">
<div class="site-name404">Time Out</div>
<!-- 创建一个id为header404的头部元素应用clearfix类可能用于清除浮动相关布局不过没看到具体的clearfix样式定义内部包含一个类名为site-name404的元素显示文本"Time Out" -->
</header>
<section>
<div class="title404">
<p>I have no secret of success but hard work.</p>
<!-- 在section元素内有一个类名为title404的div元素内部包含一个段落元素显示相应的文本内容 -->
</div><a href="javascript:history.back()" class="index404">Go back</a>
<!-- 创建一个链接元素点击时通过JavaScript的history.back()方法实现返回上一页的功能应用index404类来呈现相应的样式 -->
</section>
</div>
</div>
</body>
</html>
</html>

@ -1,28 +1,16 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!-- 这是JSP页面的指令作用如下
- contentType="text/html;charset=UTF-8"设置该JSP页面响应的内容类型为HTML格式并且指定字符编码为UTF-8确保页面中的中文等特殊字符能正确显示与传输。
- language="java"明确该页面中使用的脚本语言是Java意味着可以在页面中嵌入Java代码片段来实现业务逻辑等功能。 -->
<html>
<head>
<title>TITLE</title>
<!-- 设置HTML页面的标题在浏览器标签页等地方会显示该标题内容 -->
</head>
<body>
<%
// 以下是一段嵌入在JSP页面中的Java代码片段用于判断当前会话session中是否存在某些特定属性。
// session.getAttribute("student")==null检查名为"student"的会话属性是否不存在值为null
// session.getAttribute("teacher")==null检查名为"teacher"的会话属性是否不存在值为null
// session.getAttribute("admin")==null检查名为"admin"的会话属性是否不存在值为null
// 整体逻辑是,只有当这三个属性在会话中都不存在时,才会执行后续的转发操作。
if (session.getAttribute("student") == null && session.getAttribute("teacher") == null && session.getAttribute("admin") == null) {
if (session.getAttribute("student")==null && session.getAttribute("teacher")==null && session.getAttribute("admin")==null) {
%>
<jsp:forward page = "login.jsp"/>
<!-- 这是JSP的一个动作标签<jsp:forward>),用于将请求转发到指定的页面(这里是"login.jsp"页面)。
意味着当满足上述Java代码中判断条件时当前请求会被直接转发到"login.jsp"页面浏览器地址栏的URL可能不会发生改变取决于服务器的具体配置和实现
并且后续当前JSP页面中未执行的部分代码将不会再执行控制权交给了被转发到的"login.jsp"页面。 -->
<jsp:forward page = "login.jsp"/>
<%
}
%>
</body>
</html>
</html>

@ -1,10 +1,7 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!-- 这是JSPJava Server Pages页面的指令标签。
- contentType="text/html;charset=UTF-8"用于设定此页面响应内容的类型为HTML格式同时指定字符编码为UTF-8这样可以保证页面能够正确地显示和处理各种字符比如中文等特殊字符不会出现乱码情况。
- language="java"明确表明在这个JSP页面中所使用的脚本语言是Java意味着后续可以在页面中嵌入Java代码片段来实现诸如业务逻辑处理、数据交互等功能。 -->
<div class="layui-footer">
<!-- 这是一个HTML的<div>标签,使用了名为"layui-footer"的类名。通常在前端框架如Layui框架这样带有特定类名的元素会被赋予相应的样式此处大概率是用于构建页面底部的布局结构从注释“底部固定区域”可以推测,它可能是用来创建页面底部的固定显示区域,比如放置版权信息、相关链接等内容。 -->
<!-- 底部固定区域 -->
© yoyling.com - 学生信息管理系统
<!-- 此处显示的是版权声明相关的文本内容表明该学生信息管理系统的版权归属网站为“yoyling.com”是页面底部常见的用于标识版权所有者及系统名称的展示信息。 -->
</div>
</div>

@ -1,116 +1,65 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!-- 这是JSPJava Server Pages页面的指令标签具体作用如下
- contentType="text/html;charset=UTF-8"指定该页面响应内容的类型为HTML格式同时将字符编码设置为UTF-8确保页面能正确处理和显示各种字符像中文等特殊字符不会出现乱码现象。
- language="java"表明在这个JSP页面中使用的脚本语言是Java后续可以在页面里嵌入Java代码片段来实现诸如与服务器端交互、业务逻辑处理等功能。不过从当前整个页面来看主要还是以HTML、CSS和JavaScript实现前端相关功能为主 -->
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- 设置HTML页面的字符编码为UTF-8与上面JSP指令中的字符编码设置相呼应保证页面内容能正确解析和显示 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!-- 指示浏览器以IE的最高版本或者Chrome 1的模式来渲染页面用于解决不同浏览器之间的兼容性问题尽量保证页面在不同浏览器下呈现的效果相对一致 -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- 设置视口相关属性让页面宽度等于设备宽度初始缩放比例为1最大缩放比例也为1意味着页面在移动端等设备上初始显示时按设备宽度自适应并且用户不能进行缩放操作 -->
<title>忘记密码</title>
<!-- 设置HTML页面的标题这个标题会显示在浏览器的标签栏上让用户清楚当前页面的主要功能是用于“忘记密码”相关操作 -->
<link rel="stylesheet" href="./css/layui.css">
<!-- 引入外部样式表文件layui.css通常这是Layui前端框架的核心样式文件用于应用该框架预定义的各种UI组件、布局等样式 -->
<link rel="stylesheet" href="./css/style.css">
<!-- 引入自定义的style.css样式文件可能用于覆盖Layui框架的部分默认样式或者添加页面特定的样式规则 -->
<link rel="stylesheet" href="./css/login.css">
<!-- 引入专门针对登录相关功能此处是忘记密码功能可能和登录共用部分样式逻辑的login.css样式文件进一步定制页面的外观样式 -->
<script src="layui.js"></script>
<!-- 引入Layui框架的JavaScript核心文件通过这个文件可以使用Layui框架提供的各种JavaScript组件和功能比如表单验证、弹出层等功能 -->
</head>
<body>
<div class="frame-main">
<!-- 这可能是整个页面主体内容的一个外层框架容器,用于整体布局,通过类名"frame-main"可以在CSS样式表中对其设置宽度、高度、边距等布局相关的样式属性 -->
<div class="login-main">
<!-- 可能是专门用于放置登录相关内容(此处是忘记密码相关元素)的容器,通过类名"login-main"可以进一步定制其内部元素的排列、样式等 -->
<header class="layui-elip">找回密码</header>
<!-- 使用了layui-elip类的<header>元素可能是应用了Layui框架中特定的样式类来实现文本的某种排版效果比如省略显示等不过具体要看对应样式定义用于显示页面的主要标题“找回密码” -->
<form class="layui-form">
<!-- 创建一个表单元素并且应用了layui-form类表明这个表单会应用Layui框架提供的表单相关的样式和验证等功能 -->
<div class="layui-input-inline">
<!-- 创建一个行内块级的<div>元素,用于在表单内布局输入框等元素,使得它们可以在同一行显示(具体布局还取决于样式设置) -->
<label class="layadmin-user-login-icon layui-icon layui-icon-username"></label>
<!-- 创建一个<label>标签应用了多个类名其中layui-icon类表明它是Layui框架中的图标元素layui-icon-username类指定了具体的图标样式这里推测是代表用户名相关的图标用于在输入框前面显示一个特定的图标作为提示 -->
<input type="text" name="account" required lay-verify="required" placeholder="请输入注册时的ID" autocomplete="off"
class="layui-input">
<!-- 创建一个文本输入框,设置了以下属性:
- type="text":表明是文本类型的输入框,用于用户输入文本信息。
- name="account":为输入框设置一个名称,方便后续在表单提交等操作中识别和获取该输入框的值。
- requiredHTML5的属性表明这个输入框是必填项浏览器会进行相应的验证提示。
- lay-verify="required"Layui框架的验证属性再次强调这个输入框是必填的当用户提交表单时如果该输入框为空会触发验证提示。
- placeholder="请输入注册时的ID":在输入框为空时显示的提示文本,提示用户应该输入的内容。
- autocomplete="off":关闭浏览器的自动填充功能,避免浏览器自动填充一些不合适的信息到该输入框。
- class="layui-input"应用Layui框架中针对输入框的样式类使输入框呈现出相应的外观样式。 -->
</div>
<div class="layui-input-inline">
<label class="layadmin-user-login-icon layui-icon layui-icon-email"></label>
<input type="password" name="password" required lay-verify="required" placeholder="用于找回的邮箱" autocomplete="off"
class="layui-input">
<!-- 与上面的输入框类似不过这里是一个密码类型的输入框type="password"),用于用户输入找回密码所需要的邮箱地址,同样设置了必填、验证、提示文本等相关属性 -->
</div>
<div class="layui-input-inline login-btn">
<!-- 又是一个行内块级的<div>元素用于放置提交按钮并且应用了login-btn类可能用于对按钮设置特定的样式比如大小、颜色等 -->
<button lay-submit lay-filter="login" class="layui-btn">找回</button>
<!-- 创建一个按钮元素应用了layui-btn类使其呈现Layui框架中按钮的默认样式lay-submit属性表示这个按钮可以触发表单提交操作lay-filter="login"属性用于为按钮绑定一个特定的事件过滤器方便后续在JavaScript代码中对按钮的点击事件进行监听和处理 -->
</div>
<hr/>
<!-- 创建一个水平分割线元素,用于在页面上划分不同的区域,起到视觉上的分隔作用 -->
<p><a href="login.jsp" class="fl">登录&emsp;&emsp;&emsp;&emsp;</a><a href="https://yoyling.com" class="fl">如果你未绑定邮箱请联系我</a><a href="register.jsp" class="fr">注册</a></p>
<!-- 创建一个段落元素,里面包含了三个链接元素:
- 第一个链接href="login.jsp"指向登录页面login.jsp并应用了fl类可能用于设置左浮动等样式布局相关操作显示文本“登录”方便用户在忘记密码页面可以直接跳转到登录页面。
- 第二个链接href="https://yoyling.com"指向一个外部网站yoyling.com同样应用了fl类显示文本“如果你未绑定邮箱请联系我”用于提示用户在未绑定邮箱的情况下如何寻求帮助。
- 第三个链接href="register.jsp"指向注册页面register.jsp应用了fr类可能用于设置右浮动等样式布局相关操作显示文本“注册”方便用户进行注册相关操作。 -->
</form>
</div>
</div>
<footer style="position:absolute;bottom:0;width:100%;height:30px; text-align: center;">© 2018-2019.YOYLING.COM</footer>
<!-- 创建一个<footer>元素通过内联样式设置其绝对定位在页面底部bottom:0宽度占满整个页面width:100%高度为30px并且文本居中对齐text-align: center用于显示版权相关的声明信息“© 2018-2019.YOYLING.COM” -->
<script type="text/javascript">
layui.use(['form','layer','jquery'], function () {
// 使用Layui框架的模块加载机制加载名为'form'(用于表单操作和验证等功能)、'layer'(用于弹出层提示等功能)、'jquery'虽然这里写的是加载但实际上可能是Layui内部已经集成了jQuery或者对其进行了适配用于进行DOM操作、AJAX请求等常见的JavaScript操作的模块加载完成后执行回调函数。
// 操作对象
var form = layui.form;
// 获取Layui框架中表单模块的实例对象后续可以通过这个对象调用表单相关的方法比如进行表单验证、监听表单提交事件等操作。
var $ = layui.jquery;
// 获取Layui框架中经过适配后的jQuery对象或者就是原生的jQuery对象如果Layui是基于它来集成的方便后续进行各种DOM操作和AJAX请求等操作。
form.on('submit(login)',function (data) {
// 使用表单模块的on方法来监听表单提交事件这里监听的是lay-filter="login"的按钮点击提交表单时触发的事件。当事件触发时会传入一个包含表单数据等信息的参数data执行回调函数内的代码。
// console.log(data.field);
// 这行代码如果取消注释,可以在控制台打印出表单中各个输入框等元素提交的数据,用于调试查看用户输入的内容是否正确获取到了,此处是获取到以对象形式存储的表单数据(字段名为键,用户输入的值为对应的值)。
$.ajax({
url:'login.php',
// 设置AJAX请求的目标URL地址这里是向名为login.php的服务器端脚本文件发送请求通常这个文件会用于处理登录相关的业务逻辑此处是忘记密码的验证逻辑可能存在复用情况比如验证用户输入的账号和邮箱是否匹配等操作。
data:data.field,
// 将获取到的表单数据前面提到的data.field作为请求的数据发送给服务器端服务器端可以根据这些数据进行相应的处理。
dataType:'text',
// 设置期望从服务器端返回的数据类型为文本类型,意味着服务器端返回的内容会被当作普通文本进行处理。
type:'post',
// 设置AJAX请求的方式为POST方式相比于GET方式POST方式更适合用于提交表单数据等需要传递较多数据或者敏感数据的情况数据会放在请求体中发送给服务器端。
success:function (data) {
// 这是AJAX请求成功后的回调函数当服务器端正确响应并返回数据后会执行这个函数参数data就是服务器端返回的数据内容。
if (data == '1'){
location.href = "../index.php";
// 如果服务器端返回的数据内容是'1'则认为验证通过通过修改浏览器的地址栏将页面重定向到上级目录下的index.php页面这里推测index.php可能是系统的主页面或者登录成功后的欢迎页面等。
}else{
layer.msg('登录名或密码错误');
// 如果服务器端返回的数据不是'1'则认为验证失败使用Layui框架的layer模块弹出一个提示消息框显示“登录名或密码错误”的提示信息告知用户验证未通过的原因。
}
}
})
return false;
// 返回false阻止表单的默认提交行为因为这里已经通过AJAX方式手动向服务器端发送了请求不需要浏览器再进行默认的表单提交操作了避免页面刷新等不必要的情况发生。
})
});

@ -1,42 +1,28 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!-- 页面指令:
contentType="text/html;charset=UTF-8"指定了该JSP页面返回给客户端的内容类型是HTML格式并且字符编码采用UTF-8这样可以确保页面能够正确显示包含各种语言文字尤其是中文等非ASCII字符的内容避免出现乱码情况。
language="java"表明该JSP页面使用Java语言来编写脚本代码JSP本质上最终会被服务器编译成ServletJava类来执行这里明确了其脚本所基于的编程语言。
-->
<html>
<head>
<title>TITLE</title>
</head>
<body>
<%
// 以下这段代码基于服务器端的会话session对象来判断用户的角色并根据不同的角色进行页面转发操作。
// 它通过检查session对象中存储的特定属性student、teacher、admin是否存在来确定用户身份然后将请求转发到相应的初始页面
// 如果这些属性都不存在意味着用户未登录或者登录状态失效等情况就将请求转发到login.jsp页面让用户进行登录操作。
if (session.getAttribute("student")!= null) {
// 使用session.getAttribute("student")尝试从当前会话中获取名为student的属性值
// 如果获取到的值不为null表示当前用户的角色是学生此时执行下面的转发操作
// 利用JSP的转发标签<jsp:forward>将请求转发到WEB-INF/student/sIndex.jsp页面。
// WEB-INF目录下的资源通常是受保护的不能直接通过浏览器URL访问需要通过服务器端的转发等内部机制来访问这样可以提高页面的安全性避免用户直接绕过权限检查去访问一些应该有权限限制的页面。
if (session.getAttribute("student")!=null) {
%>
<jsp:forward page="/WEB-INF/student/sIndex.jsp" />
<jsp:forward page = "/WEB-INF/student/sIndex.jsp"/>
<%
} else if (session.getAttribute("teacher")!= null) {
// 类似地如果student属性不存在但是teacher属性存在于会话中说明用户角色是教师就会把请求转发到WEB-INF/teacher/tIndex.jsp页面。
}else if (session.getAttribute("teacher")!=null) {
%>
<jsp:forward page="/WEB-INF/teacher/tIndex.jsp" />
<jsp:forward page = "/WEB-INF/teacher/tIndex.jsp"/>
<%
} else if (session.getAttribute("admin")!= null) {
// 若student和teacher属性都不存在而admin属性存在表明用户是管理员角色会将请求转发到WEB-INF/admin/aIndex.jsp页面。
}else if (session.getAttribute("admin")!=null) {
%>
<jsp:forward page="/WEB-INF/admin/aIndex.jsp" />
<jsp:forward page = "/WEB-INF/admin/aIndex.jsp"/>
<%
} else {
// 前面几个条件都不满足也就是上述代表不同角色的属性在会话中都不存在时会将请求转发到login.jsp页面引导用户进行登录
// 建立相应的会话属性来标识其角色,后续再次访问时就能根据角色转发到对应的页面了。
}else {
%>
<jsp:forward page="login.jsp" />
<jsp:forward page = "login.jsp" />
<%
}
%>
</body>
</html>
</html>

@ -1,157 +1,2 @@
/** layui-v2.5.6 MIT License By https://www.layui.com */
;layui.define("jquery",function(e){"use strict";
// 引入 layui 的 $jQuery模块
var i=layui.$,
// 初始化配置对象
n=(layui.hint(),layui.device(),{config:{},set:function(e){
var n=this;
// 设置配置
return n.config=i.extend({},n.config,e),n},
on:function(e,i){
return layui.onevent.call(this,t,e,i)}}),
// 定义常量
t="carousel", // 轮播图的名称
a="layui-this", // 当前活动的元素
l=">*[carousel-item]>*", // 选择轮播图的每一个项目
o="layui-carousel-left", // 左箭头
r="layui-carousel-right", // 右箭头
d="layui-carousel-prev", // 上一项按钮
s="layui-carousel-next", // 下一项按钮
u="layui-carousel-arrow", // 箭头
c="layui-carousel-ind", // 指示器(小圆点)
// 定义轮播图的核心功能
m=function(e){
var t=this;
t.config=i.extend({},t.config,n.config,e),t.render()
};
// 轮播图的默认配置
m.prototype.config={
width:"600px", // 默认宽度
height:"280px", // 默认高度
full:!1, // 是否全屏
arrow:"hover", // 箭头显示方式hover即鼠标悬浮时显示
indicator:"inside", // 指示器的位置inside表示在轮播图内
autoplay:!0, // 是否自动播放
interval:3e3, // 自动播放的间隔时间,单位是毫秒
anim:"", // 动画效果
trigger:"click", // 触发方式:点击
index:0 // 默认显示第0项
},
// 渲染轮播图
m.prototype.render=function(){
var e=this,n=e.config;
n.elem=i(n.elem),
n.elem[0]&&(e.elemItem=n.elem.find(l),n.index<0&&(n.index=0),n.index>=e.elemItem.length&&(n.index=e.elemItem.length-1),n.interval<800&&(n.interval=800),n.full?n.elem.css({position:"fixed",width:"100%",height:"100%",zIndex:9999}):n.elem.css({width:n.width,height:n.height}),n.elem.attr("lay-anim",n.anim),e.elemItem.eq(n.index).addClass(a),e.elemItem.length<=1||(e.indicator(),e.arrow(),e.autoplay(),e.events()))
},
// 重新加载轮播图
m.prototype.reload=function(e){
var n=this;
clearInterval(n.timer),
n.config=i.extend({},n.config,e),
n.render()
},
// 获取上一项的索引
m.prototype.prevIndex=function(){
var e=this,i=e.config,n=i.index-1;
return n<0&&(n=e.elemItem.length-1),n
},
// 获取下一项的索引
m.prototype.nextIndex=function(){
var e=this,i=e.config,n=i.index+1;
return n>=e.elemItem.length&&(n=0),n
},
// 增加索引
m.prototype.addIndex=function(e){
var i=this,n=i.config;
e=e||1,n.index=n.index+e,n.index>=i.elemItem.length&&(n.index=0)
},
// 减少索引
m.prototype.subIndex=function(e){
var i=this,n=i.config;
e=e||1,n.index=n.index-e,n.index<0&&(n.index=i.elemItem.length-1)
},
// 自动播放
m.prototype.autoplay=function(){
var e=this,i=e.config;
i.autoplay&&(clearInterval(e.timer),e.timer=setInterval(function(){
e.slide()
},i.interval))
},
// 箭头按钮
m.prototype.arrow=function(){
var e=this,n=e.config,t=i(['<button class="layui-icon '+u+'" lay-type="sub">'+("updown"===n.anim?"&#xe619;":"&#xe603;")+"</button>",
'<button class="layui-icon '+u+'" lay-type="add">'+("updown"===n.anim?"&#xe61a;":"&#xe602;")+"</button>"].join(""));
// 设置箭头的显示方式
n.elem.attr("lay-arrow",n.arrow),
n.elem.find("."+u)[0]&&n.elem.find("."+u).remove(),
n.elem.append(t),
t.on("click",function(){
var n=i(this),t=n.attr("lay-type");
e.slide(t)
})
},
// 指示器
m.prototype.indicator=function(){
var e=this,n=e.config,t=e.elemInd=i(['<div class="'+c+'"><ul>',function(){
var i=[];
return layui.each(e.elemItem,function(e){
i.push("<li"+(n.index===e?' class="layui-this"':"")+"></li>")
}),i.join("")
}(),"</ul></div>"].join(""));
// 设置指示器的显示方式
n.elem.attr("lay-indicator",n.indicator),
n.elem.find("."+c)[0]&&n.elem.find("."+c).remove(),
n.elem.append(t),"updown"===n.anim&&t.css("margin-top",-(t.height()/2)),
t.find("li").on("hover"===n.trigger?"mouseover":n.trigger,function(){
var t=i(this),a=t.index();
a>n.index?e.slide("add",a-n.index):a<n.index&&e.slide("sub",n.index-a)
})
},
// 切换轮播图
m.prototype.slide=function(e,i){
var n=this,l=n.elemItem,u=n.config,c=u.index,m=u.elem.attr("lay-filter");
n.haveSlide||("sub"===e?(n.subIndex(i),l.eq(u.index).addClass(d),setTimeout(function(){
l.eq(c).addClass(r),l.eq(u.index).addClass(r)
},50)):(n.addIndex(i),l.eq(u.index).addClass(s),setTimeout(function(){
l.eq(c).addClass(o),l.eq(u.index).addClass(o)
},50)),setTimeout(function(){
l.removeClass(a+" "+d+" "+s+" "+o+" "+r),l.eq(u.index).addClass(a),
n.haveSlide=!1
},300),n.elemInd.find("li").eq(u.index).addClass(a).siblings().removeClass(a),
n.haveSlide=!0,layui.event.call(this,t,"change("+m+")",{index:u.index,prevIndex:c,item:l.eq(u.index)}))
},
// 事件绑定
m.prototype.events=function(){
var e=this,i=e.config;
i.elem.data("haveEvents")||(i.elem.on("mouseenter",function(){
clearInterval(e.timer)
}).on("mouseleave",function(){
e.autoplay()
}),i.elem.data("haveEvents",!0))
},
// 初始化轮播图
n.render=function(e){
var i=new m(e);
return i
},
// 触发layui事件
e(t,n)
});
;layui.define("jquery",function(e){"use strict";var i=layui.$,n=(layui.hint(),layui.device(),{config:{},set:function(e){var n=this;return n.config=i.extend({},n.config,e),n},on:function(e,i){return layui.onevent.call(this,t,e,i)}}),t="carousel",a="layui-this",l=">*[carousel-item]>*",o="layui-carousel-left",r="layui-carousel-right",d="layui-carousel-prev",s="layui-carousel-next",u="layui-carousel-arrow",c="layui-carousel-ind",m=function(e){var t=this;t.config=i.extend({},t.config,n.config,e),t.render()};m.prototype.config={width:"600px",height:"280px",full:!1,arrow:"hover",indicator:"inside",autoplay:!0,interval:3e3,anim:"",trigger:"click",index:0},m.prototype.render=function(){var e=this,n=e.config;n.elem=i(n.elem),n.elem[0]&&(e.elemItem=n.elem.find(l),n.index<0&&(n.index=0),n.index>=e.elemItem.length&&(n.index=e.elemItem.length-1),n.interval<800&&(n.interval=800),n.full?n.elem.css({position:"fixed",width:"100%",height:"100%",zIndex:9999}):n.elem.css({width:n.width,height:n.height}),n.elem.attr("lay-anim",n.anim),e.elemItem.eq(n.index).addClass(a),e.elemItem.length<=1||(e.indicator(),e.arrow(),e.autoplay(),e.events()))},m.prototype.reload=function(e){var n=this;clearInterval(n.timer),n.config=i.extend({},n.config,e),n.render()},m.prototype.prevIndex=function(){var e=this,i=e.config,n=i.index-1;return n<0&&(n=e.elemItem.length-1),n},m.prototype.nextIndex=function(){var e=this,i=e.config,n=i.index+1;return n>=e.elemItem.length&&(n=0),n},m.prototype.addIndex=function(e){var i=this,n=i.config;e=e||1,n.index=n.index+e,n.index>=i.elemItem.length&&(n.index=0)},m.prototype.subIndex=function(e){var i=this,n=i.config;e=e||1,n.index=n.index-e,n.index<0&&(n.index=i.elemItem.length-1)},m.prototype.autoplay=function(){var e=this,i=e.config;i.autoplay&&(clearInterval(e.timer),e.timer=setInterval(function(){e.slide()},i.interval))},m.prototype.arrow=function(){var e=this,n=e.config,t=i(['<button class="layui-icon '+u+'" lay-type="sub">'+("updown"===n.anim?"&#xe619;":"&#xe603;")+"</button>",'<button class="layui-icon '+u+'" lay-type="add">'+("updown"===n.anim?"&#xe61a;":"&#xe602;")+"</button>"].join(""));n.elem.attr("lay-arrow",n.arrow),n.elem.find("."+u)[0]&&n.elem.find("."+u).remove(),n.elem.append(t),t.on("click",function(){var n=i(this),t=n.attr("lay-type");e.slide(t)})},m.prototype.indicator=function(){var e=this,n=e.config,t=e.elemInd=i(['<div class="'+c+'"><ul>',function(){var i=[];return layui.each(e.elemItem,function(e){i.push("<li"+(n.index===e?' class="layui-this"':"")+"></li>")}),i.join("")}(),"</ul></div>"].join(""));n.elem.attr("lay-indicator",n.indicator),n.elem.find("."+c)[0]&&n.elem.find("."+c).remove(),n.elem.append(t),"updown"===n.anim&&t.css("margin-top",-(t.height()/2)),t.find("li").on("hover"===n.trigger?"mouseover":n.trigger,function(){var t=i(this),a=t.index();a>n.index?e.slide("add",a-n.index):a<n.index&&e.slide("sub",n.index-a)})},m.prototype.slide=function(e,i){var n=this,l=n.elemItem,u=n.config,c=u.index,m=u.elem.attr("lay-filter");n.haveSlide||("sub"===e?(n.subIndex(i),l.eq(u.index).addClass(d),setTimeout(function(){l.eq(c).addClass(r),l.eq(u.index).addClass(r)},50)):(n.addIndex(i),l.eq(u.index).addClass(s),setTimeout(function(){l.eq(c).addClass(o),l.eq(u.index).addClass(o)},50)),setTimeout(function(){l.removeClass(a+" "+d+" "+s+" "+o+" "+r),l.eq(u.index).addClass(a),n.haveSlide=!1},300),n.elemInd.find("li").eq(u.index).addClass(a).siblings().removeClass(a),n.haveSlide=!0,layui.event.call(this,t,"change("+m+")",{index:u.index,prevIndex:c,item:l.eq(u.index)}))},m.prototype.events=function(){var e=this,i=e.config;i.elem.data("haveEvents")||(i.elem.on("mouseenter",function(){clearInterval(e.timer)}).on("mouseleave",function(){e.autoplay()}),i.elem.data("haveEvents",!0))},n.render=function(e){var i=new m(e);return i},e(t,n)});

@ -1,58 +1,2 @@
/** layui-v2.5.6 MIT License By https://www.layui.com */
;layui.define("jquery",function(e){"use strict";
// 引入 layui 的 $jQuery模块
var a=layui.$,
// layui 文档模块的 URL 地址
l="http://www.layui.com/doc/modules/code.html";
// 定义模块 "code",并执行传入的函数
e("code",function(e){
var t=[]; // 初始化一个空数组,用于存储每个代码块元素
// 如果 e 参数未定义,则默认为空对象
e=e||{},
// 如果 e 中没有指定 about则默认为 true
e.about=!("about"in e)||e.about,
// 获取所有指定的代码块元素,默认为 .layui-code
e.elem=a(e.elem||".layui-code"),
// 遍历所有代码块元素
e.elem.each(function(){
t.push(this); // 将每个代码块元素添加到数组 t 中
}),
// 倒序遍历每个代码块元素
layui.each(t.reverse(),function(t,i){
var c=a(i), // 获取当前代码块元素
o=c.html(); // 获取当前代码块的 HTML 内容
// 如果代码块元素有 lay-encode 属性或者传入参数 e.encode 为真,进行 HTML 转义
(c.attr("lay-encode")||e.encode)&&(o=o.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&amp;")
.replace(/</g,"&lt;")
.replace(/>/g,"&gt;")
.replace(/'/g,"&#39;")
.replace(/"/g,"&quot;"));
// 将转义后的 HTML 内容分行显示,每行一个 <li> 元素
c.html('<ol class="layui-code-ol"><li>'+o.replace(/[\r\t\n]+/g,"</li><li>")+"</li></ol>");
// 如果没有标题插入一个标题h3标题内容可以通过 lay-title 来指定
c.find(">.layui-code-h3")[0] || c.prepend('<h3 class="layui-code-h3">'+(c.attr("lay-title")||e.title||"code")+(e.about?'<a href="'+l+'" target="_blank">layui.code</a>':"")+"</h3>");
// 获取代码块中的 <ol> 元素
var d=c.find(">.layui-code-ol");
// 为代码块添加类名,设置样式
c.addClass("layui-box layui-code-view"),
// 如果有指定 skin 或 lay-skin给代码块添加相应的样式
(c.attr("lay-skin")||e.skin) && c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),
// 如果代码行数超过100行设置左边距使其有缩进效果
(d.find("li").length/100|0)>0 && d.css("margin-left",(d.find("li").length/100|0)+"px"),
// 如果指定了 lay-height 或者传入的参数 e.height设置最大高度
(c.attr("lay-height")||e.height) && d.css("max-height",c.attr("lay-height")||e.height)
})
})})
// 引入代码块的 CSS 样式
.addcss("modules/code.css","skincodecss");
;layui.define("jquery",function(e){"use strict";var a=layui.$,l="http://www.layui.com/doc/modules/code.html";e("code",function(e){var t=[];e=e||{},e.elem=a(e.elem||".layui-code"),e.about=!("about"in e)||e.about,e.elem.each(function(){t.push(this)}),layui.each(t.reverse(),function(t,i){var c=a(i),o=c.html();(c.attr("lay-encode")||e.encode)&&(o=o.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;")),c.html('<ol class="layui-code-ol"><li>'+o.replace(/[\r\t\n]+/g,"</li><li>")+"</li></ol>"),c.find(">.layui-code-h3")[0]||c.prepend('<h3 class="layui-code-h3">'+(c.attr("lay-title")||e.title||"code")+(e.about?'<a href="'+l+'" target="_blank">layui.code</a>':"")+"</h3>");var d=c.find(">.layui-code-ol");c.addClass("layui-box layui-code-view"),(c.attr("lay-skin")||e.skin)&&c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),(d.find("li").length/100|0)>0&&d.css("margin-left",(d.find("li").length/100|0)+"px"),(c.attr("lay-height")||e.height)&&d.css("max-height",c.attr("lay-height")||e.height)})})}).addcss("modules/code.css","skincodecss");

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,118 +1,2 @@
/** layui-v2.5.6 MIT License By https://www.layui.com */
;layui.define("jquery", function(e) {
"use strict";
var l = layui.$, o = function(e) {}, t = '<i class="layui-anim layui-anim-rotate layui-anim-loop layui-icon ">&#xe63e;</i>';
// 定义 load 方法,用于加载更多内容
o.prototype.load = function(e) {
var o, i, n, r, a = this, c = 0;
e = e || {};
var f = l(e.elem); // 获取加载更多按钮所在的元素
if (f[0]) { // 如果该元素存在
var m = l(e.scrollElem || document), // 获取滚动容器元素,默认为 document
u = e.mb || 50, // 滚动到距离底部多少距离时触发加载更多
s = !("isAuto" in e) || e.isAuto, // 是否自动加载
v = e.end || "没有更多了", // 加载完成后的提示
y = e.scrollElem && e.scrollElem !== document, // 判断是否是自定义滚动区域
d = "<cite>加载更多</cite>", // 默认的加载更多文本
h = l('<div class="layui-flow-more"><a href="javascript:;">' + d + "</a></div>");
f.find(".layui-flow-more")[0] || f.append(h); // 如果没有加载更多的按钮,则追加
var p = function(e, t) {
e = l(e);
h.before(e); // 将新内容插入到加载更多按钮之前
t = 0 == t || null;
t ? h.html(v) : h.find("a").html(d); // 如果已加载完毕,显示“没有更多了”
i = t;
o = null;
n && n();
};
// 加载更多逻辑
var g = function() {
o = !0;
h.find("a").html(t); // 显示加载动画
"function" == typeof e.done && e.done(++c, p); // 如果有 done 方法,调用它
};
// 初始化加载
g();
// 点击加载更多时,触发加载操作
h.find("a").on("click", function() {
l(this);
i || o || g();
});
// 如果启用了懒加载
if (e.isLazyimg) var n = a.lazyimg({ elem: e.elem + " img", scrollElem: e.scrollElem });
return s ? (m.on("scroll", function() {
var e = l(this), t = e.scrollTop();
r && clearTimeout(r);
!i && f.width() && (r = setTimeout(function() {
var i = y ? e.height() : l(window).height(),
n = y ? e.prop("scrollHeight") : document.documentElement.scrollHeight;
// 滚动到底部时加载更多
n - t - i <= u && (o || g());
}, 100));
}), a) : a;
}
};
// 懒加载方法
o.prototype.lazyimg = function(e) {
var o, t = this, i = 0;
e = e || {};
var n = l(e.scrollElem || document), r = e.elem || "img", a = e.scrollElem && e.scrollElem !== document;
// 图片加载检查和设置
var c = function(e, l) {
var o = n.scrollTop(), r = o + l, c = a ? function() {
return e.offset().top - n.offset().top + o;
}() : e.offset().top;
if (c >= o && c <= r && !e.attr("src")) {
var m = e.attr("lay-src");
layui.img(m, function() {
var l = t.lazyimg.elem.eq(i);
e.attr("src", m).removeAttr("lay-src");
l[0] && f(l);
i++;
});
}
};
// 触发懒加载
var f = function(e, o) {
var f = a ? (o || n).height() : l(window).height(), m = n.scrollTop(), u = m + f;
t.lazyimg.elem = l(r);
if (e) c(e, f);
else {
for (var s = 0; s < t.lazyimg.elem.length; s++) {
var v = t.lazyimg.elem.eq(s),
y = a ? function() {
return v.offset().top - n.offset().top + m;
}() : v.offset().top;
if (c(v, f), i = s, y > u) break;
}
}
};
// 初次加载图片
f();
if (!o) {
var m;
n.on("scroll", function() {
var e = l(this);
m && clearTimeout(m);
m = setTimeout(function() {
f(null, e);
}, 50);
});
o = !0;
}
return f;
};
// 定义模块接口
e("flow", new o);
});
;layui.define("jquery",function(e){"use strict";var l=layui.$,o=function(e){},t='<i class="layui-anim layui-anim-rotate layui-anim-loop layui-icon ">&#xe63e;</i>';o.prototype.load=function(e){var o,i,n,r,a=this,c=0;e=e||{};var f=l(e.elem);if(f[0]){var m=l(e.scrollElem||document),u=e.mb||50,s=!("isAuto"in e)||e.isAuto,v=e.end||"没有更多了",y=e.scrollElem&&e.scrollElem!==document,d="<cite>加载更多</cite>",h=l('<div class="layui-flow-more"><a href="javascript:;">'+d+"</a></div>");f.find(".layui-flow-more")[0]||f.append(h);var p=function(e,t){e=l(e),h.before(e),t=0==t||null,t?h.html(v):h.find("a").html(d),i=t,o=null,n&&n()},g=function(){o=!0,h.find("a").html(t),"function"==typeof e.done&&e.done(++c,p)};if(g(),h.find("a").on("click",function(){l(this);i||o||g()}),e.isLazyimg)var n=a.lazyimg({elem:e.elem+" img",scrollElem:e.scrollElem});return s?(m.on("scroll",function(){var e=l(this),t=e.scrollTop();r&&clearTimeout(r),!i&&f.width()&&(r=setTimeout(function(){var i=y?e.height():l(window).height(),n=y?e.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-i<=u&&(o||g())},100))}),a):a}},o.prototype.lazyimg=function(e){var o,t=this,i=0;e=e||{};var n=l(e.scrollElem||document),r=e.elem||"img",a=e.scrollElem&&e.scrollElem!==document,c=function(e,l){var o=n.scrollTop(),r=o+l,c=a?function(){return e.offset().top-n.offset().top+o}():e.offset().top;if(c>=o&&c<=r&&!e.attr("src")){var m=e.attr("lay-src");layui.img(m,function(){var l=t.lazyimg.elem.eq(i);e.attr("src",m).removeAttr("lay-src"),l[0]&&f(l),i++})}},f=function(e,o){var f=a?(o||n).height():l(window).height(),m=n.scrollTop(),u=m+f;if(t.lazyimg.elem=l(r),e)c(e,f);else for(var s=0;s<t.lazyimg.elem.length;s++){var v=t.lazyimg.elem.eq(s),y=a?function(){return v.offset().top-n.offset().top+m}():v.offset().top;if(c(v,f),i=s,y>u)break}};if(f(),!o){var m;n.on("scroll",function(){var e=l(this);m&&clearTimeout(m),m=setTimeout(function(){f(null,e)},50)}),o=!0}return f},e("flow",new o)});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save