庞纪辉 #3

Merged
pj3mtvxnl merged 1 commits from pjh_beach1 into develop 1 year ago

@ -4,11 +4,11 @@ package service;
import domain.Admin;
/**
*
*
*/
public interface AdminService {
/**
*
*
*/
Admin login(Admin admin);

@ -7,7 +7,7 @@ import domain.CDC;
import java.util.List;
/**
*
* -
*/
public interface CDCService {
List<CDC> findAllCollege();

@ -5,7 +5,7 @@ import domain.Complaint;
import java.util.List;
/**
*
* -
*/
public interface ComplaintService {
List<Complaint> findAll();

@ -1,7 +1,9 @@
package service;
import domain.Course;
/**
*
*/
public interface CourseService {
void addOptionalCourse(Course course);

@ -5,11 +5,11 @@ import domain.Notify;
import java.util.List;
/**
*
* -
*/
public interface NotifyService {
/**
*
* -
*/
void addNotify(Notify notify);

@ -1,7 +1,9 @@
package service;
import domain.Photo;
/**
*
*/
public interface PhotoService {
void addPhoto(Photo photo);

@ -3,7 +3,9 @@ package service;
import domain.SelectCourse;
import java.util.List;
/**
*
*/
public interface SelectCourseService {
List<SelectCourse> findStudentSelectedCourseByCourseId(String cid);

@ -8,11 +8,11 @@ import java.util.List;
import java.util.Map;
/**
*
* -
*/
public interface StudentService {
/**
*
* -
* @param currentPage
* @param rows
* @param condition
@ -21,7 +21,7 @@ public interface StudentService {
PageBean<Student> findStudentByPage(String currentPage, String rows, Map<String, String[]> condition);
/**
*
* -
*/
List<Student> findAll();
@ -49,3 +49,42 @@ public interface StudentService {
List<SelectCourse> findSelectCourseAllStudent();
}
//public interface StudentService {
// /**
// * 分页条件查询-
// * @param currentPage
// * @param rows
// * @param condition
// * @return
// */
// PageBean<Student> findStudentByPage(String currentPage, String rows, Map<String, String[]> condition);
//
// /**
// * 查询所有学生信息-
// */
// List<Student> findAll();
//
// Student login(Student student);
//
// Student findStudentById(Student student);
//
// void register(Student student);
//
// void updateInfo(Student student);
//
// void updatePassword(String studentid, String newpassword);
//
// List<SelectCourse> findAllSelectCourse(String studentid);
//
// List<Course> findAllOptionalCourse();
//
// void addSelectCourse(String studentid, String courseid);
//
// void deleteStudentById(String studentid);
//
// void deleteSelectStudent(String[] sids);
//
// void addStudentAllInfo(Student updateStudent);
//
// List<SelectCourse> findSelectCourseAllStudent();
//}

@ -6,11 +6,11 @@ import domain.Teacher;
import java.util.List;
/**
*
* -
*/
public interface TeacherService {
/**
*
* -
*/
Teacher login(Teacher teacher);
@ -33,4 +33,30 @@ public interface TeacherService {
void deleteTeacherById(String teacherid);
void updateInfo(Teacher updateTeacher);
}
}
//public interface TeacherService {
// /**
// * 教师登录-
// */
// Teacher login(Teacher teacher);
//
// List<Teacher> findAll();
//
// List<Course> findMySelfOptionalCourse(String T_id);
//
// Course findOptionalCourseByCourseId(String cid);
//
// void updateCourseInfo(Course updateCourse);
//
// void deleteCourseById(String cid);
//
// void updatePassword(String teacherid, String newpassword);
//
// Teacher findTeacherById(Teacher teacher);
//
// void addTeacherAllInfo(Teacher updateTeacher);
//
// void deleteTeacherById(String teacherid);
//
// void updateInfo(Teacher updateTeacher);
//}

@ -10,7 +10,7 @@ import java.sql.Statement;
import java.util.Properties;
/**
* Druid,dao
* Druid,dao-
*/
public class JDBCUtils {
private static DataSource dataSource; //定义成员变量DataSource
@ -28,14 +28,14 @@ public class JDBCUtils {
}
/**
*
* -
*/
public static Connection getConnection() throws SQLException {
return dataSource.getConnection();
}
/**
*
* -
*/
public static void close(Statement statement,Connection connection) {
close(null,statement,connection);
@ -68,9 +68,71 @@ public class JDBCUtils {
}
/**
*
* -
*/
public static DataSource getDataSource() {
return dataSource;
}
}
//public class JDBCUtils {
// private static DataSource dataSource; //定义成员变量DataSource
// static {
// try {
// //加载配置文件
// Properties properties = new Properties();
// properties.load(JDBCUtils.class.getClassLoader().getResourceAsStream("druid.properties"));
//
// //获取DataSource
// dataSource = DruidDataSourceFactory.createDataSource(properties);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// /**
// * 获取连接-
// */
// public static Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// /**
// * 释放资源-
// */
// public static void close(Statement statement,Connection connection) {
// close(null,statement,connection);
// }
//
// public static void close(ResultSet resultSet, Statement statement, Connection connection) {
// if (resultSet != null) {
// try {
// resultSet.close();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//
// if (statement != null) {
// try {
// statement.close();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//
// if (connection != null) {
// try {
// connection.close();//归还连接
// }catch (SQLException e) {
// e.printStackTrace();
// }
// }
// }
//
// /**
// * 获取连接池方法-
// */
// public static DataSource getDataSource() {
// return dataSource;
// }
//}

@ -17,7 +17,7 @@ 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 s = new Student();
s.setS_id(sid);
@ -59,7 +59,7 @@ public class AddStudentInfoServlet extends HttpServlet {
updateStudent.setS_class(cclass);
service.addStudentAllInfo(updateStudent);
request.setAttribute("update_msg","添加成功!"+String.format("%tT",new Date()));
request.setAttribute("update_msg","添加成功!"+String.format("%tT",new Date()));//返回添加信息
request.getRequestDispatcher("addStudentServlet").forward(request, response);
}

@ -16,12 +16,17 @@ 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 service2 = new CDCServiceImpl();
List<CDC> collegeList = service2.findAllCollege();
List<CDC> departmentList = service2.findAllDepartment();

@ -8,7 +8,11 @@ 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);
}

@ -15,7 +15,9 @@ 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 {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

@ -13,9 +13,18 @@ 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
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
HttpSession session = request.getSession();

@ -46,12 +46,12 @@ public class UpdateStudentInfoServlet extends HttpServlet {
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 {
//封装学生对象
//封装学生对象-
updateStudent.setS_id(sid);
updateStudent.setS_name(name);
updateStudent.setS_sex(sex);
@ -63,7 +63,7 @@ public class UpdateStudentInfoServlet extends HttpServlet {
updateStudent.setS_department(department);
updateStudent.setS_class(cclass);
//调用studentUpdata服务
//调用studentUpdata服务-
StudentService service= new StudentServiceImpl();
service.updateInfo(updateStudent);

@ -26,10 +26,12 @@ public class UpdateStudentServlet extends HttpServlet {
Student student = new Student();
student.setS_id(studentid);
// 创建学生服务的实现类实例,用于处理与学生相关的业务逻辑
StudentService service = new StudentServiceImpl();
Student newStudent = service.findStudentById(student);
request.setAttribute("student",newStudent);
// 创建 CDCService 的实现类实例,用于处理与院系、系别和班级相关的业务逻辑
CDCService service2 = new CDCServiceImpl();
List<CDC> collegeList = service2.findAllCollege();
List<CDC> departmentList = service2.findAllDepartment();

@ -22,10 +22,10 @@ import java.util.List;
public class CDCListServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
//调用StudentService完成查询
//调用StudentService完成查询-
CDCService service = new CDCServiceImpl();
List<CDC> cdcs = service.findAll();
//将list存入request域
//将list存入request域-
request.setAttribute("cdcs",cdcs);
HttpSession session = request.getSession();

@ -19,7 +19,7 @@ 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");

@ -11,13 +11,16 @@ 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 {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
ComplaintService service = new ComplaintServiceImpl();
List<Complaint> complaints = service.findAll();
// 将查询到的投诉信息存入请求属性,以便在后续的 JSP 页面中使用
request.setAttribute("complaints",complaints);
request.getRequestDispatcher("/WEB-INF/complaint/complaintsList.jsp").forward(request,response);
}

@ -11,16 +11,26 @@ 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以支持中文字符的正确处理
request.setCharacterEncoding("utf-8");
ComplaintService service = new ComplaintServiceImpl();
List<Complaint> complaints = service.findAll();
request.setAttribute("complaints",complaints);
request.getRequestDispatcher("/WEB-INF/complaint/complaintsList.jsp").forward(request,response);
}
/**
* GETPOST
*
* @param request HTTP
* @param response HTTP
* @throws IOException
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);

@ -7,9 +7,20 @@ 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
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String fileName = request.getParameter("filename");

@ -14,9 +14,19 @@ 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
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String filename = request.getParameter("filename");
if (filename.equalsIgnoreCase("../") || filename.equalsIgnoreCase("/")) {

@ -25,7 +25,7 @@ public class FileListServlet extends HttpServlet {
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();
@ -62,14 +62,14 @@ public class FileListServlet extends HttpServlet {
}
public static String getPrintSize(long size) {
// 如果字节数少于1024则直接以B为单位否则先除于1024后3位因太少无意义
// 如果字节数少于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作为单位
// 如果原字节数除于1024之后少于1024则可以直接以KB作为单位-
// 因为还没有到达要使用另一个单位的时候
// 接下去以此类推
if (value < 1024) {

@ -6,13 +6,31 @@ 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);
}
/**
* GETPOST
*
* @param request HTTP
* @param response HTTP
* @throws ServletException
* @throws IOException
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}

@ -58,13 +58,13 @@ public class ShowPhotoServlet extends HttpServlet {
if (imagePath.toLowerCase().endsWith(".jpg"))// 使用编码处理文件流的情况:
{
response.setContentType(JPG);// 设定输出的类型
// 得到图片的真实路径
// 得到图片的真实路径-
// 得到图片的文件流
// 得到图片的文件流-
InputStream imageIn = new FileInputStream(new File(imagePath));
// 得到输入的编码器将文件流进行jpg格式编码
// 得到输入的编码器将文件流进行jpg格式编码-
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(imageIn);
// 得到编码后的图片对象
// 得到编码后的图片对象-
BufferedImage image = decoder.decodeAsBufferedImage();
// 得到输出的编码器
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(output);

@ -41,29 +41,29 @@ public class UploadImageServlet extends HttpServlet {
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、创建一个文件上传解析器
// 2、创建一个文件上传解析器-
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setHeaderEncoding("UTF-8");
// 3、判断提交上来的数据是否是上传表单的数据
// 3、判断提交上来的数据是否是上传表单的数据-
if (!ServletFileUpload.isMultipartContent(request)) {
// 按照传统方式获取数据
// 按照传统方式获取数据-
return;
}
try {
List<FileItem> list = upload.parseRequest(request);
System.out.println(list.toString());// 文件的路径 以及保存的路径
System.out.println(list.toString());// 文件的路径 以及保存的路径-
for (FileItem item : list) {
filename = item.getName();// 获得一个项的文件名称
filename = item.getName();// 获得一个项的文件名称-
try {
newFileName = id + filename.substring(filename.lastIndexOf("."));
filename = id + filename.substring(filename.lastIndexOf("."));

@ -15,9 +15,20 @@ 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
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
@ -93,6 +104,9 @@ public class UploadServlet extends HttpServlet {
}
}
/**
*
*/
class ProcessInfo{
public long totalSize = 1;
public long readSize = 0;

@ -6,9 +6,19 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* Servlet
*/
@WebServlet("/adminIndexServlet")
public class AdminIndexServlet extends HttpServlet {
/**
* POSTJSP
*
* @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/aIndex.jsp").forward(request,response);
}

@ -6,9 +6,19 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* Servlet
*/
@WebServlet("/studentIndexServlet")
public class StudentIndexServlet extends HttpServlet {
/**
* POSTJSP
*
* @param request HTTP
* @param response HTTP
* @throws ServletException
* @throws IOException
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("/WEB-INF/student/sIndex.jsp").forward(request,response);
}

@ -7,8 +7,19 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* Servlet
*/
@WebServlet("/teacherIndexServlet")
public class TeacherIndexServlet extends HttpServlet {
/**
* POSTJSP
*
* @param request HTTP
* @param response HTTP
* @throws ServletException
* @throws IOException
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("/WEB-INF/teacher/tIndex.jsp").forward(request,response);
}

@ -13,9 +13,19 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* Servlet
*/
@WebServlet("/findStudentServlet")
public class FindStudentServlet extends HttpServlet {
/**
* POSTID
*
* @param request HTTP
* @param response HTTP
* @throws ServletException
* @throws IOException
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/json;charset=utf-8");
String studentId = request.getParameter("studentid");
@ -34,7 +44,7 @@ public class FindStudentServlet extends HttpServlet {
map.put("studentExsit", false);
map.put("msg", "用户名可用");
}
//map转为json传给客户端
//map转为json传给客户端-
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(response.getWriter(),map);
} catch (Exception e) {

@ -32,38 +32,38 @@ public class LoginServlet extends HttpServlet {
Teacher loginTeacher = null;
Admin loginAdmin = null;
//设置编码
//设置编码-
request.setCharacterEncoding("utf-8");
//获取数据
//获取数据-
String verifycode = request.getParameter("verifycode");
String loginid = request.getParameter("id");
String loginpassword = request.getParameter("password");
//验证码校验
//验证码校验-
HttpSession session = request.getSession();
String checkcode_server = (String) session.getAttribute("CHECKCODE_SERVER");
session.removeAttribute("CHECKCODE_SERVER");//确保验证一次性
if (checkcode_server == null || !checkcode_server.equalsIgnoreCase(verifycode)) {
//验证码不正确
//验证码不正确-
request.setAttribute("login_msg","验证码错误");
//跳转页面
//跳转页面-
request.setAttribute("loginid",loginid);
request.setAttribute("loginpassword",loginpassword);
request.getRequestDispatcher("/login.jsp").forward(request,response);
return;
}
//封装对象
//封装对象-
String id = request.getParameter("id");
String password = request.getParameter("password");
String roles = request.getParameter("roles");
//公告加载
//公告加载-
NotifyService notifyService= new NotifyServiceImpl();
List<Notify> notifys = notifyService.find();
session.setAttribute("notifys",notifys);
//判断roles封装对象、保存session、调用不同Service查询
//判断roles封装对象、保存session、调用不同Service查询-
if ("student".equals(roles)) {
Student student = new Student();
@ -79,7 +79,7 @@ public class LoginServlet extends HttpServlet {
// request.getRequestDispatcher("/WEB-INF/student/sIndex.jsp").forward(request,response);
response.sendRedirect("studentIndexServlet");
}else {
//登录失败 提示信息
//登录失败 提示信息-
request.setAttribute("login_msg", "用户名或密码错误!");
request.setAttribute("loginid",loginid);
request.setAttribute("loginpassword",loginpassword);
@ -100,7 +100,7 @@ public class LoginServlet extends HttpServlet {
// request.getRequestDispatcher("/WEB-INF/teacher/tIndex.jsp").forward(request, response);
response.sendRedirect("teacherIndexServlet");
}else {
//登录失败 提示信息
//登录失败 提示信息-
request.setAttribute("login_msg", "用户名或密码错误!");
request.getRequestDispatcher("/login.jsp").forward(request, response);
}
@ -120,7 +120,7 @@ public class LoginServlet extends HttpServlet {
// request.getRequestDispatcher("/WEB-INF/admin/aIndex.jsp").forward(request,response);
response.sendRedirect("adminIndexServlet");
}else {
//登录失败 提示信息
//登录失败 提示信息-
request.setAttribute("login_msg", "用户名或密码错误!");
request.getRequestDispatcher("/login.jsp").forward(request, response);
}

@ -7,9 +7,19 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
/**
* Servlet
*/
@WebServlet("/logoutServlet")
public class LogoutServlet extends HttpServlet {
/**
* POST
*
* @param request HTTP
* @param response HTTP
* @throws ServletException
* @throws IOException
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
HttpSession session = request.getSession();

@ -8,10 +8,21 @@ 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();
String studentid = request.getParameter("studentid");
String password = request.getParameter("password");

@ -22,7 +22,7 @@ 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();

@ -11,10 +11,21 @@ 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 {
/**
* POSTID
*
* @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");

@ -11,11 +11,23 @@ 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);

@ -15,11 +15,23 @@ 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);

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

@ -18,7 +18,9 @@ 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");//每页显示条数
@ -30,14 +32,14 @@ public class FindStudentByPageServlet extends HttpServlet {
rows = "5";
}
//获取条件查询参数
//获取条件查询参数-
Map<String,String[]> condition = request.getParameterMap();
StudentService service = new StudentServiceImpl();
PageBean<Student> pb = service.findStudentByPage(currentPage,rows,condition);
request.setAttribute("pb",pb);
request.setAttribute("condition",condition);//存入查询条件
request.setAttribute("condition",condition);//存入查询条件-
request.setCharacterEncoding("utf-8");
HttpSession session = request.getSession();
Student student= (Student)session.getAttribute("student");

@ -11,15 +11,26 @@ 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");
// 重定向到查找学生的页面
response.sendRedirect(request.getContextPath() + "/findStudentByPageServlet");
}
// 处理GET请求直接调用doPost方法
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
doPost(request, response);
}
}

@ -14,18 +14,34 @@ 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);
// request.getRequestDispatcher("/findStudentByPageServlet").forward(request,response);
// 重定向到查找学生的页面
response.sendRedirect("findStudentByPageServlet");
// 如果需要使用转发,可以使用下面的代码
// request.getRequestDispatcher("/findStudentByPageServlet").forward(request, response);
}
// 处理GET请求直接调用doPost方法
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
doPost(request, response);
}
}

@ -24,6 +24,16 @@ public class DoSelectCourseServlet extends HttpServlet {
Student student= (Student)session.getAttribute("student");
String courseid = request.getParameter("id");
//存不存在已选该课
//1
//2
//3
//4
//5
//6
//7
//8
//9
//0
boolean flag = false;
//判断是否已选

@ -27,3 +27,17 @@ public class StudentInfomationServlet extends HttpServlet {
doPost(request,response);
}
}
//public class StudentInfomationServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//// HttpSession session = request.getSession();
//// Student s = (Student) session.getAttribute("student");
//// StudentService service = new StudentServiceImpl();
//// Student newStudent = service.findStudentById(s);
//// session.setAttribute("student",newStudent);
// request.getRequestDispatcher("/WEB-INF/student/sInformation.jsp").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -20,7 +20,7 @@ public class StudentInfomationUpdateServlet extends HttpServlet {
request.setCharacterEncoding("utf-8");
//保存输入内容
//保存输入内容-
String sid = request.getParameter("student-id");
String name = request.getParameter("student-name");
String sex = request.getParameter("student-sex");
@ -31,18 +31,28 @@ public class StudentInfomationUpdateServlet extends HttpServlet {
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 {
//封装学生对象
//封装学生对象-
updateStudent.setS_id(sid);
updateStudent.setS_name(name);
updateStudent.setS_sex(sex);
@ -53,8 +63,18 @@ public class StudentInfomationUpdateServlet extends HttpServlet {
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服务
//调用studentUpdata服务-
StudentService service= new StudentServiceImpl();
service.updateInfo(updateStudent);
@ -63,7 +83,7 @@ public class StudentInfomationUpdateServlet extends HttpServlet {
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);

@ -18,10 +18,10 @@ import java.util.List;
@WebServlet("/studentListServlet")
public class StudentListServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//调用StudentService完成查询
//调用StudentService完成查询-
StudentService studentService = new StudentServiceImpl();
List<Student> students = studentService.findAll();
//将list存入request域
//将list存入request域-
request.setAttribute("students",students);
request.setCharacterEncoding("utf-8");
@ -40,6 +40,19 @@ public class StudentListServlet extends HttpServlet {
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);

@ -24,12 +24,12 @@ public class StudentOptionalCourseServlet extends HttpServlet {
Student student= (Student)session.getAttribute("student");
Admin admin =(Admin)session.getAttribute("admin");
//调用StudentService完成查询
//调用StudentService完成查询-
StudentService studentService = new StudentServiceImpl();
List<Course> optionalcourses = studentService.findAllOptionalCourse();
//将list存入request域
//将list存入request域-
request.setAttribute("optionalcourses",optionalcourses);
//转发到list.jsp
//转发到list.jsp-
if (student != null && admin == null) {
request.getRequestDispatcher("/WEB-INF/student/studentOptionalCourse.jsp").forward(request,response);
@ -38,6 +38,13 @@ public class StudentOptionalCourseServlet extends HttpServlet {
} 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);
// }
}

@ -8,12 +8,26 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/studentPasswordIndexServlet")
// 学生密码修改索引Servlet
public class StudentPasswordIndexServlet extends HttpServlet {
// 处理POST请求
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("/WEB-INF/student/studentUpdatePassword.jsp").forward(request,response);
// 转发请求到学生密码修改页面
request.getRequestDispatcher("/WEB-INF/student/studentUpdatePassword.jsp").forward(request, response);
}
// 处理GET请求直接调用doPost方法
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
doPost(request, response);
}
}
//public class StudentPasswordIndexServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.getRequestDispatcher("/WEB-INF/student/studentUpdatePassword.jsp").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -14,8 +14,11 @@ 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以支持中文
request.setCharacterEncoding("utf-8");
HttpSession session = request.getSession();
Student student= (Student)session.getAttribute("student");
@ -45,6 +48,35 @@ public class StudentPasswordUpdateServlet extends HttpServlet {
}
}
// 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);

@ -25,13 +25,13 @@ public class StudentSelectCourseListServlet extends HttpServlet {
Student student= (Student)session.getAttribute("student");
Admin admin =(Admin)session.getAttribute("admin");
//调用StudentService完成查询
//调用StudentService完成查询-
StudentService studentService = new StudentServiceImpl();
if (student != null && admin == null) {
List<SelectCourse> selectcourses = studentService.findAllSelectCourse(student.getS_id());
//将list存入request域
//将list存入request域-
request.setAttribute("selectcourses",selectcourses);
//转发到list.jsp
//转发到list.jsp-
request.getRequestDispatcher("/WEB-INF/student/studentSelectCourseList.jsp").forward(request,response);
} else if (admin != null && student == null) {
List<SelectCourse> selectcourses = studentService.findSelectCourseAllStudent();
@ -48,3 +48,34 @@ public class StudentSelectCourseListServlet extends HttpServlet {
this.doPost(request,response);
}
}
//public class StudentSelectCourseListServlet 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");
// Admin admin =(Admin)session.getAttribute("admin");
//
// //调用StudentService完成查询-
// StudentService studentService = new StudentServiceImpl();
// if (student != null && admin == null) {
// List<SelectCourse> selectcourses = studentService.findAllSelectCourse(student.getS_id());
// //将list存入request域-
// request.setAttribute("selectcourses",selectcourses);
// //转发到list.jsp-
// 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);
// }
//
//
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// this.doPost(request,response);
// }
//}

@ -8,12 +8,30 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/studentServlet")
// 学生相关操作的Servlet
public class StudentServlet extends HttpServlet {
// 处理POST请求
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("/WEB-INF/student/sIndex.jsp").forward(request,response);
// 转发请求到学生首页
request.getRequestDispatcher("/WEB-INF/student/sIndex.jsp").forward(request, response);
}
// 处理GET请求直接调用doPost方法
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
doPost(request, response);
}
}
//public class StudentServlet extends HttpServlet {
//
// // 处理POST请求
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 转发请求到学生首页
// request.getRequestDispatcher("/WEB-INF/student/sIndex.jsp").forward(request, response);
// }
//
// // 处理GET请求直接调用doPost方法
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request, response);
// }
//}

@ -15,11 +15,16 @@ import java.io.IOException;
import java.util.Date;
@WebServlet("/addOptionalCourseServlet")
// 添加选修课程的Servlet
public class AddOptionalCourseServlet extends HttpServlet {
// 处理POST请求
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");
String cid = request.getParameter("cid");
@ -49,3 +54,41 @@ public class AddOptionalCourseServlet extends HttpServlet {
doPost(request,response);
}
}
//public class AddOptionalCourseServlet extends HttpServlet {
// // 处理POST请求
// 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");
//
// String cid = request.getParameter("cid");
// String cname = request.getParameter("course-name");
// String cinfo = request.getParameter("course-info");
//
// CourseService service = new CourseServiceImpl();
// Course course = service.findSelectCourseByCourseId(cid);
// if (course != null) {
// 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();
// newCourse.setC_id(cid);
// newCourse.setC_name(cname);
// newCourse.setC_info(cinfo);
// newCourse.setT_id(teacher.getT_id());
// newCourse.setT_name(teacher.getT_name());
//
// service.addOptionalCourse(newCourse);
// request.setAttribute("update_msg","课程添加成功!"+String.format("%tT",new Date()));
// request.getRequestDispatcher("/WEB-INF/teacher/addOptionalCourse.jsp").forward(request,response);
// }
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -9,12 +9,38 @@ import java.io.IOException;
@WebServlet("/addSelectCourseServlet")
public class AddSelectCourseServlet extends HttpServlet {
// 处理POST请求的方法
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求字符编码为UTF-8以支持中文字符
request.setCharacterEncoding("utf-8");
request.getRequestDispatcher("/WEB-INF/teacher/addOptionalCourse.jsp").forward(request,response);
// 将请求转发到指定的JSP页面
// "/WEB-INF/teacher/addOptionalCourse.jsp" 是要转发到的JSP页面路径
request.getRequestDispatcher("/WEB-INF/teacher/addOptionalCourse.jsp").forward(request, response);
}
// 处理GET请求的方法
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
// 对于GET请求调用doPost方法进行处理
doPost(request, response);
}
}
//public class AddSelectCourseServlet extends HttpServlet {
//
// // 处理POST请求的方法
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求字符编码为UTF-8以支持中文字符
// request.setCharacterEncoding("utf-8");
//
// // 将请求转发到指定的JSP页面
// // "/WEB-INF/teacher/addOptionalCourse.jsp" 是要转发到的JSP页面路径
// request.getRequestDispatcher("/WEB-INF/teacher/addOptionalCourse.jsp").forward(request, response);
// }
//
// // 处理GET请求的方法
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 对于GET请求调用doPost方法进行处理
// doPost(request, response);
// }
//}

@ -17,7 +17,7 @@ public class AddTeacherInfoServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
TeacherService service= new TeacherServiceImpl();
//先进行判断是否已存在该教师
//先进行判断是否已存在该教师-
String tid = request.getParameter("teacher-id");
Teacher t = new Teacher();
t.setT_id(tid);
@ -31,18 +31,18 @@ public class AddTeacherInfoServlet extends HttpServlet {
String education = request.getParameter("teacher-education");
String title = request.getParameter("teacher-title");
// String college = request.getParameter("selectCollege");
// String department = request.getParameter("selectDepartment");
// String cclass = request.getParameter("selectClass");
// if ("".equals(college)) {
// college = "待分配";
// }
// if ("".equals(department)) {
// department = "待分配";
// }
// if ("".equals(cclass)) {
// cclass = "待分配";
// }
// String college = request.getParameter("selectCollege");-
// String department = request.getParameter("selectDepartment");-
// String cclass = request.getParameter("selectClass");-
// if ("".equals(college)) {-
// college = "待分配";-
// }-
// if ("".equals(department)) {-
// department = "待分配";-
// }-
// if ("".equals(cclass)) {-
// cclass = "待分配";-
// }-
Teacher updateTeacher = new Teacher();
@ -51,9 +51,9 @@ public class AddTeacherInfoServlet extends HttpServlet {
updateTeacher.setT_sex(sex);
updateTeacher.setT_education(education);
updateTeacher.setT_title(title);
// updateTeacher.setT_college(college);
// updateTeacher.setT_department(department);
// updateTeacher.setT_class(cclass);
// updateTeacher.setT_college(college);-
// updateTeacher.setT_department(department);-
// updateTeacher.setT_class(cclass);-
service.addTeacherAllInfo(updateTeacher);
request.setAttribute("update_msg", "添加成功!" + String.format("%tT", new Date()));
@ -65,3 +65,55 @@ public class AddTeacherInfoServlet extends HttpServlet {
doPost(request,response);
}
}
//public class AddTeacherInfoServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.setCharacterEncoding("utf-8");
// TeacherService service= new TeacherServiceImpl();
// //先进行判断是否已存在该教师-
// String tid = request.getParameter("teacher-id");
// Teacher t = new Teacher();
// t.setT_id(tid);
// Teacher newTeacher = service.findTeacherById(t);
// if (newTeacher != null) {
// request.setAttribute("update_msg","已存在该教师,请重新添加!"+String.format("%tT",new Date()));
// request.getRequestDispatcher("addTeacherServlet").forward(request, response);
// }else {
// String name = request.getParameter("teacher-name");
// String sex = request.getParameter("teacher-sex");
// String education = request.getParameter("teacher-education");
// String title = request.getParameter("teacher-title");
//
//// String college = request.getParameter("selectCollege");-
//// String department = request.getParameter("selectDepartment");-
//// String cclass = request.getParameter("selectClass");-
//// if ("".equals(college)) {-
//// college = "待分配";-
//// }-
//// if ("".equals(department)) {-
//// department = "待分配";-
//// }-
//// if ("".equals(cclass)) {-
//// cclass = "待分配";-
//// }-
//
// Teacher updateTeacher = new Teacher();
//
// updateTeacher.setT_id(tid);
// updateTeacher.setT_name(name);
// updateTeacher.setT_sex(sex);
// updateTeacher.setT_education(education);
// updateTeacher.setT_title(title);
//// updateTeacher.setT_college(college);-
//// updateTeacher.setT_department(department);-
//// updateTeacher.setT_class(cclass);-
//
// service.addTeacherAllInfo(updateTeacher);
// request.setAttribute("update_msg", "添加成功!" + String.format("%tT", new Date()));
// request.getRequestDispatcher("addTeacherServlet").forward(request, response);
// }
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -15,6 +15,7 @@ import java.util.List;
@WebServlet("/addTeacherServlet")
public class AddTeacherServlet extends HttpServlet {
//注册
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
HttpSession session = request.getSession();
@ -35,3 +36,25 @@ public class AddTeacherServlet extends HttpServlet {
doPost(request,response);
}
}
//public class AddTeacherServlet extends HttpServlet {
// //注册
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.setCharacterEncoding("utf-8");
// HttpSession session = request.getSession();
//
// CDCService service = new CDCServiceImpl();
// List<CDC> collegeList = service.findAllCollege();
// List<CDC> departmentList = service.findAllDepartment();
// List<CDC> classList = service.findAllClass();
//
// session.setAttribute("collegeLists",collegeList);
// session.setAttribute("departmentLists",departmentList);
// session.setAttribute("classLists",classList);
//
// request.getRequestDispatcher("/WEB-INF/admin/addTeacher.jsp").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -13,15 +13,54 @@ import java.io.IOException;
@WebServlet("/deleteOptionalCourseServlet")
public class DeleteOptionalCourseServlet extends HttpServlet {
// 处理POST请求的方法
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求字符编码为UTF-8以支持中文字符
request.setCharacterEncoding("utf-8");
// 获取请求 "cid"表示要删除的课程ID
String cid = request.getParameter("cid");
// 创建教师服务的实现类实例
TeacherService service = new TeacherServiceImpl();
// 调用服务层方法根据课程ID删除课程
service.deleteCourseById(cid);
request.getRequestDispatcher("/teacherOptionalCourseServlet").forward(request,response);
// 请求转发到教师可选课程的Servlet以更新课程列表
request.getRequestDispatcher("/teacherOptionalCourseServlet").forward(request, response);
}
// 处理GET请求的方法
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
// 对于GET请求调用doPost方法进行处理
doPost(request, response);
}
}
//public class DeleteOptionalCourseServlet extends HttpServlet {
//
// // 处理POST请求的方法
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 设置请求字符编码为UTF-8以支持中文字符
// request.setCharacterEncoding("utf-8");
//
// // 获取请求 "cid"表示要删除的课程ID
// String cid = request.getParameter("cid");
//
// // 创建教师服务的实现类实例
// TeacherService service = new TeacherServiceImpl();
//
// // 调用服务层方法根据课程ID删除课程
// service.deleteCourseById(cid);
//
// // 请求转发到教师可选课程的Servlet以更新课程列表
// request.getRequestDispatcher("/teacherOptionalCourseServlet").forward(request, response);
// }
//
// // 处理GET请求的方法
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// // 对于GET请求调用doPost方法进行处理
// doPost(request, response);
// }
//}

@ -12,6 +12,7 @@ import javax.servlet.http.HttpSession;
import java.io.IOException;
@WebServlet("/deleteTeacherServlet")
//教师服务页面
public class DeleteTeacherServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
@ -25,3 +26,16 @@ public class DeleteTeacherServlet extends HttpServlet {
doPost(request,response);
}
}
//public class DeleteTeacherServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.setCharacterEncoding("utf-8");
// String teacherid = request.getParameter("tid");
// TeacherService service = new TeacherServiceImpl();
// service.deleteTeacherById(teacherid);
// request.getRequestDispatcher("/teacherListServlet").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -13,8 +13,10 @@ import java.io.IOException;
import java.util.List;
@WebServlet("/findStudentCourseScoreServlet")
//不清楚什么作用
public class FindStudentCourseScoreServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//中文
request.setCharacterEncoding("utf-8");
String cid = request.getParameter("cid");
System.out.println(cid);
@ -34,3 +36,25 @@ public class FindStudentCourseScoreServlet extends HttpServlet {
doPost(request,response);
}
}
//public class FindStudentCourseScoreServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// //中文
// request.setCharacterEncoding("utf-8");
// String cid = request.getParameter("cid");
// System.out.println(cid);
//
// SelectCourseService service = new SelectCourseServiceImpl();
// List<SelectCourse> scs = service.findStudentSelectedCourseByCourseId(cid);
// for (int i = 0; i < scs.size(); i++) {
// System.out.println(scs.get(i));
// }
//
// request.setAttribute("scs",scs);
// request.getRequestDispatcher("/WEB-INF/teacher/findSelectCourseListByCourseId.jsp").forward(request,response);
//
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -11,6 +11,7 @@ import javax.servlet.http.HttpSession;
import java.io.IOException;
@WebServlet("/teacherInfomationServlet")
//网络页面
public class TeacherInfomationServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("/WEB-INF/teacher/tInformation.jsp").forward(request,response);
@ -20,3 +21,12 @@ public class TeacherInfomationServlet extends HttpServlet {
doPost(request,response);
}
}
//public class TeacherInfomationServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.getRequestDispatcher("/WEB-INF/teacher/tInformation.jsp").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -20,10 +20,10 @@ import java.util.List;
@WebServlet("/teacherListServlet")
public class TeacherListServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//调用TeacherService完成查询
//调用TeacherService完成查询-
TeacherService teacherService = new TeacherServiceImpl();
List<Teacher> teachers = teacherService.findAll();
//将list存入request域
//将list存入request域-
request.setAttribute("teachers",teachers);
request.setCharacterEncoding("utf-8");
@ -46,3 +46,31 @@ public class TeacherListServlet extends HttpServlet {
this.doPost(request,response);
}
}
//public class TeacherListServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// //调用TeacherService完成查询-
// TeacherService teacherService = new TeacherServiceImpl();
// List<Teacher> teachers = teacherService.findAll();
// //将list存入request域-
// request.setAttribute("teachers",teachers);
//
// 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);
// }
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// this.doPost(request,response);
// }
//}

@ -24,12 +24,12 @@ public class TeacherOptionalCourseServlet extends HttpServlet {
HttpSession session = request.getSession();
Teacher t = (Teacher) session.getAttribute("teacher");
if (t != null) {
//调用StudentService完成查询
//调用StudentService完成查询-
TeacherService service = new TeacherServiceImpl();
List<Course> optionalcourses = service.findMySelfOptionalCourse(t.getT_id());
//将list存入request域
//将list存入request域-
request.setAttribute("optionalcourses",optionalcourses);
//转发到list.jsp
//转发到list.jsp-
request.getRequestDispatcher("/WEB-INF/teacher/teacherOptionalCourse.jsp").forward(request,response);
}
}
@ -38,3 +38,23 @@ public class TeacherOptionalCourseServlet extends HttpServlet {
this.doPost(request,response);
}
}
//public class TeacherOptionalCourseServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.setCharacterEncoding("utf-8");
// HttpSession session = request.getSession();
// Teacher t = (Teacher) session.getAttribute("teacher");
// if (t != null) {
// //调用StudentService完成查询-
// TeacherService service = new TeacherServiceImpl();
// List<Course> optionalcourses = service.findMySelfOptionalCourse(t.getT_id());
// //将list存入request域-
// request.setAttribute("optionalcourses",optionalcourses);
// //转发到list.jsp-
// request.getRequestDispatcher("/WEB-INF/teacher/teacherOptionalCourse.jsp").forward(request,response);
// }
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// this.doPost(request,response);
// }
//}

@ -21,27 +21,27 @@ public class TeacherOptionalCourseUpdateServlet extends HttpServlet {
String cid =request.getParameter("cid");
//保存输入内容
//保存输入内容-
String name = request.getParameter("course-name");
String info = request.getParameter("course-info");
Course updateCourse = new Course();
//判断输入位数是否大于数据库位数
//判断输入位数是否大于数据库位数-
if (cid.contains("<") || name.contains("<") || info.contains("<")) {
request.setAttribute("update_msg","格式错误,请重新提交!"+String.format("%tT",new Date()));
request.getRequestDispatcher("updateTeacherOptionalCourseServlet?cid="+cid).forward(request, response);
}else {
//封装学生对象
//封装学生对象-
updateCourse.setC_id(cid);
updateCourse.setC_name(name);
updateCourse.setC_info(info);
//调用studentUpdata服务
//调用studentUpdata服务-
TeacherService service= new TeacherServiceImpl();
service.updateCourseInfo(updateCourse);
//成功则返回并给提示
//成功则返回并给提示-
request.setAttribute("update_msg", "修改成功!"+String.format("%tT",new Date()));
request.getRequestDispatcher("updateTeacherOptionalCourseServlet?cid="+cid).forward(request, response);
}
@ -51,3 +51,39 @@ public class TeacherOptionalCourseUpdateServlet extends HttpServlet {
doPost(request,response);
}
}
//public class TeacherOptionalCourseUpdateServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.setCharacterEncoding("utf-8");
//
// String cid =request.getParameter("cid");
//
// //保存输入内容-
// String name = request.getParameter("course-name");
// String info = request.getParameter("course-info");
//
// Course updateCourse = new Course();
//
// //判断输入位数是否大于数据库位数-
// if (cid.contains("<") || name.contains("<") || info.contains("<")) {
// request.setAttribute("update_msg","格式错误,请重新提交!"+String.format("%tT",new Date()));
// request.getRequestDispatcher("updateTeacherOptionalCourseServlet?cid="+cid).forward(request, response);
// }else {
// //封装学生对象-
// updateCourse.setC_id(cid);
// updateCourse.setC_name(name);
// updateCourse.setC_info(info);
//
// //调用studentUpdata服务-
// TeacherService service= new TeacherServiceImpl();
// service.updateCourseInfo(updateCourse);
//
// //成功则返回并给提示-
// request.setAttribute("update_msg", "修改成功!"+String.format("%tT",new Date()));
// request.getRequestDispatcher("updateTeacherOptionalCourseServlet?cid="+cid).forward(request, response);
// }
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/teacherPasswordIndexServlet")
//网络服务
public class TeacherPasswordIndexServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("/WEB-INF/teacher/teacherUpdatePassword.jsp").forward(request,response);
@ -17,3 +18,12 @@ public class TeacherPasswordIndexServlet extends HttpServlet {
doPost(request,response);
}
}
//public class TeacherPasswordIndexServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.getRequestDispatcher("/WEB-INF/teacher/teacherUpdatePassword.jsp").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -16,14 +16,16 @@ import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Date;
@WebServlet("/teacherPasswordUpdateServlet")
@WebServlet("/teacherPasswordUpdateServlet")//1
public class TeacherPasswordUpdateServlet extends HttpServlet {
//2
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
HttpSession session = request.getSession();
Teacher teacher = (Teacher)session.getAttribute("teacher");
String teacherid = teacher.getT_id();
//3
String newpassword = request.getParameter("teacher-newpassword");
String ennewpassword = request.getParameter("teacher-ennewpassword");
String regex = "^[\\w]{3,12}$";
@ -53,3 +55,41 @@ public class TeacherPasswordUpdateServlet extends HttpServlet {
doPost(request,response);
}
}
//public class TeacherPasswordUpdateServlet extends HttpServlet {
// //2
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.setCharacterEncoding("utf-8");
// HttpSession session = request.getSession();
// Teacher teacher = (Teacher)session.getAttribute("teacher");
//
// String teacherid = teacher.getT_id();
// //3
// 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 service= new TeacherServiceImpl();
// service.updatePassword(teacherid,newpassword);
//
// Teacher newTeacher = service.findTeacherById(teacher);
// teacher = newTeacher;
// session.setAttribute("teacher",teacher);
//
// request.setAttribute("update_msg", "修改成功!" + String.format("%tT", new Date()));
// request.getRequestDispatcher("/WEB-INF/teacher/teacherUpdatePassword.jsp").forward(request, response);
// }
//
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -21,11 +21,14 @@ import java.io.IOException;
import java.util.Date;
@WebServlet("/updateOptionalCourseScoreServlet")
//啊
public class UpdateOptionalCourseScoreServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String cid = request.getParameter("cid");
//咦
String sid = request.getParameter("sid");
String sScore = request.getParameter("student-score");
StudentService service = new StudentServiceImpl();
@ -40,6 +43,7 @@ public class UpdateOptionalCourseScoreServlet extends HttpServlet {
Student s = service.findStudentById(student);
Course c = service1.findSelectCourseByCourseId(cid);
SelectCourse sc = service2.findScoreByCourseIdAndStudentId(cid,sid);
//什么
request.setAttribute("s",s);
request.setAttribute("c",c);
@ -52,3 +56,36 @@ public class UpdateOptionalCourseScoreServlet extends HttpServlet {
doPost(request,response);
}
}
//public class UpdateOptionalCourseScoreServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 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();
//
// service2.upDateScoreByCidAndSid(cid,sid,sScore);
//
// Student student = new Student();
// student.setS_id(sid);
//
// Student s = service.findStudentById(student);
// Course c = service1.findSelectCourseByCourseId(cid);
// SelectCourse sc = service2.findScoreByCourseIdAndStudentId(cid,sid);
// //什么
//
// request.setAttribute("s",s);
// request.setAttribute("c",c);
// request.setAttribute("sc",sc);
// request.setAttribute("update_msg","修改分数成功!"+String.format("%tT",new Date()));
// request.getRequestDispatcher("/WEB-INF/teacher/updateOptionalCourseScore.jsp").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -18,8 +18,10 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/updateScoreServlet")
//i
public class UpdateScoreServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//中文
request.setCharacterEncoding("utf-8");
String cid = request.getParameter("cid");
String sid = request.getParameter("sid");
@ -45,3 +47,31 @@ public class UpdateScoreServlet extends HttpServlet {
doPost(request,response);
}
}
//public class UpdateScoreServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// //中文
// request.setCharacterEncoding("utf-8");
// String cid = request.getParameter("cid");
// String sid = request.getParameter("sid");
//
// StudentService service = new StudentServiceImpl();
// Student student = new Student();
// student.setS_id(sid);
// Student s = service.findStudentById(student);
//
// CourseService service1 = new CourseServiceImpl();
// Course c = service1.findSelectCourseByCourseId(cid);
//
// SelectCourseService service2 = new SelectCourseServiceImpl();
// SelectCourse sc = service2.findScoreByCourseIdAndStudentId(cid,sid);
//
// request.setAttribute("s",s);
// request.setAttribute("c",c);
// request.setAttribute("sc",sc);
// request.getRequestDispatcher("/WEB-INF/teacher/updateOptionalCourseScore.jsp").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -26,23 +26,23 @@ public class UpdateTeacherInfoServlet extends HttpServlet {
String title = request.getParameter("teacher-title");
Teacher updateTeacher = new Teacher();
//判断输入位数是否大于数据库位数
//判断输入位数是否大于数据库位数-
if (name.length() > 4 || education.length() > 20 || title.length()>24 || name.contains("<") || education.contains("<") || title.contains("<")) {
request.setAttribute("update_msg","格式错误,请重新提交!"+String.format("%tT",new Date()));
request.getRequestDispatcher("updateTeacherServlet?tid="+tid).forward(request, response);
}else {
//封装教师对象
//封装教师对象-
updateTeacher.setT_id(tid);
updateTeacher.setT_name(name);
updateTeacher.setT_sex(sex);
updateTeacher.setT_education(education);
updateTeacher.setT_title(title);
//调用TeacherUpdate服务
//调用TeacherUpdate服务-
TeacherService service = new TeacherServiceImpl();
service.updateInfo(updateTeacher);
//成功则返回并给提示
//成功则返回并给提示-
request.setAttribute("update_msg", "修改成功!" + String.format("%tT", new Date()));
request.getRequestDispatcher("updateTeacherServlet?tid=" + tid).forward(request, response);
}
@ -52,3 +52,40 @@ public class UpdateTeacherInfoServlet extends HttpServlet {
doPost(request,response);
}
}
//public class UpdateTeacherInfoServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.setCharacterEncoding("utf-8");
// 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();
// //判断输入位数是否大于数据库位数-
// if (name.length() > 4 || education.length() > 20 || title.length()>24 || name.contains("<") || education.contains("<") || title.contains("<")) {
// request.setAttribute("update_msg","格式错误,请重新提交!"+String.format("%tT",new Date()));
// request.getRequestDispatcher("updateTeacherServlet?tid="+tid).forward(request, response);
// }else {
// //封装教师对象-
// updateTeacher.setT_id(tid);
// updateTeacher.setT_name(name);
// updateTeacher.setT_sex(sex);
// updateTeacher.setT_education(education);
// updateTeacher.setT_title(title);
//
// //调用TeacherUpdate服务-
// TeacherService service = new TeacherServiceImpl();
// service.updateInfo(updateTeacher);
//
// //成功则返回并给提示-
// request.setAttribute("update_msg", "修改成功!" + String.format("%tT", new Date()));
// request.getRequestDispatcher("updateTeacherServlet?tid=" + tid).forward(request, response);
// }
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -17,7 +17,7 @@ import java.util.List;
public class UpdateTeacherOptionalCourseServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
// HttpSession session = request.getSession();
// HttpSession session = request.getSession();-
String cid = (String)request.getParameter("cid");
TeacherService service = new TeacherServiceImpl();
Course c = service.findOptionalCourseByCourseId(cid);
@ -33,3 +33,22 @@ public class UpdateTeacherOptionalCourseServlet extends HttpServlet {
doPost(request,response);
}
}
//public class UpdateTeacherOptionalCourseServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.setCharacterEncoding("utf-8");
//// HttpSession session = request.getSession();-
// String cid = (String)request.getParameter("cid");
// TeacherService service = new TeacherServiceImpl();
// Course c = service.findOptionalCourseByCourseId(cid);
// request.setAttribute("course",c);
// 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);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -21,6 +21,7 @@ import java.io.IOException;
import java.util.List;
@WebServlet("/updateTeacherServlet")
//1
public class UpdateTeacherServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
@ -34,6 +35,7 @@ public class UpdateTeacherServlet extends HttpServlet {
request.setAttribute("teacher",newTeacher);
CDCService service2 = new CDCServiceImpl();
//2
List<CDC> collegeList = service2.findAllCollege();
List<CDC> departmentList = service2.findAllDepartment();
List<CDC> classList = service2.findAllClass();
@ -49,3 +51,32 @@ public class UpdateTeacherServlet extends HttpServlet {
doPost(request,response);
}
}
//public class UpdateTeacherServlet extends HttpServlet {
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// request.setCharacterEncoding("utf-8");
// HttpSession session = request.getSession();
// String teacherid = request.getParameter("tid");
//
// Teacher teacher = new Teacher();
// teacher.setT_id(teacherid);
// TeacherService service = new TeacherServiceImpl();
// Teacher newTeacher = service.findTeacherById(teacher);
// request.setAttribute("teacher",newTeacher);
//
// CDCService service2 = new CDCServiceImpl();
// //2
// List<CDC> collegeList = service2.findAllCollege();
// List<CDC> departmentList = service2.findAllDepartment();
// List<CDC> classList = service2.findAllClass();
//
// session.setAttribute("collegeLists",collegeList);
// session.setAttribute("departmentLists",departmentList);
// session.setAttribute("classLists",classList);
//
// request.getRequestDispatcher("/WEB-INF/admin/updateTeacher.jsp").forward(request,response);
// }
//
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// doPost(request,response);
// }
//}

@ -20,52 +20,52 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* -
*/
@WebServlet("/checkCodeServlet")
public class CheckCodeServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
//服务器通知浏览器不要缓存
//服务器通知浏览器不要缓存-
response.setHeader("pragma","no-cache");
response.setHeader("cache-control","no-cache");
response.setHeader("expires","0");
//在内存中创建一个长80宽30的图片默认黑色背景
//参数一:长
//参数二:宽
//参数三:颜色
//在内存中创建一个长80宽30的图片默认黑色背景-
//参数一:长-
//参数二:宽-
//参数三:颜色-
int width = 136;
int height = 38;
BufferedImage image = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
//获取画笔
//获取画笔-
Graphics g = image.getGraphics();
//设置画笔颜色为灰色
//设置画笔颜色为灰色-
g.setColor(Color.GRAY);
//填充图片
//填充图片-
g.fillRect(0,0, width,height);
//产生4个随机验证码12Ey
//产生4个随机验证码12Ey-
String checkCode = getCheckCode();
//将验证码放入HttpSession中
//将验证码放入HttpSession中-
request.getSession().setAttribute("CHECKCODE_SERVER",checkCode);
//设置画笔颜色为黄色
//设置画笔颜色为黄色-
g.setColor(Color.YELLOW);
//设置字体的小大
//设置字体的小大-
g.setFont(new Font("黑体",Font.BOLD,30));
//向图片上写入验证码
//向图片上写入验证码-
g.drawString(checkCode,36,28);
//将内存中的图片输出到浏览器
//参数一:图片对象
//参数二图片的格式如PNG,JPG,GIF
//参数三:图片输出到哪里去
//将内存中的图片输出到浏览器-
//参数一:图片对象-
//参数二图片的格式如PNG,JPG,GIF-
//参数三:图片输出到哪里去-
ImageIO.write(image,"PNG",response.getOutputStream());
}
/**
* 4
* 4 -
*/
private String getCheckCode() {
String base = "23456789ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz";
@ -73,11 +73,11 @@ public class CheckCodeServlet extends HttpServlet {
Random r = new Random();
StringBuffer sb = new StringBuffer();
for(int i=1;i<=4;i++){
//产生0到size-1的随机值
//产生0到size-1的随机值-
int index = r.nextInt(size);
//在base字符串中获取下标为index的字符
//在base字符串中获取下标为index的字符-
char c = base.charAt(index);
//将c放入到StringBuffer中去
//将c放入到StringBuffer中去-
sb.append(c);
}
return sb.toString();
@ -86,6 +86,68 @@ public class CheckCodeServlet extends HttpServlet {
this.doGet(request,response);
}
}
//public class CheckCodeServlet extends HttpServlet {
// public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
//
// //服务器通知浏览器不要缓存-
// response.setHeader("pragma","no-cache");
// response.setHeader("cache-control","no-cache");
// response.setHeader("expires","0");
//
// //在内存中创建一个长80宽30的图片默认黑色背景-
// //参数一:长-
// //参数二:宽-
// //参数三:颜色-
// int width = 136;
// int height = 38;
// BufferedImage image = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
//
// //获取画笔-
// Graphics g = image.getGraphics();
// //设置画笔颜色为灰色-
// g.setColor(Color.GRAY);
// //填充图片-
// g.fillRect(0,0, width,height);
//
// //产生4个随机验证码12Ey-
// String checkCode = getCheckCode();
// //将验证码放入HttpSession中-
// request.getSession().setAttribute("CHECKCODE_SERVER",checkCode);
//
// //设置画笔颜色为黄色-
// g.setColor(Color.YELLOW);
// //设置字体的小大-
// g.setFont(new Font("黑体",Font.BOLD,30));
// //向图片上写入验证码-
// g.drawString(checkCode,36,28);
//
// //将内存中的图片输出到浏览器-
// //参数一:图片对象-
// //参数二图片的格式如PNG,JPG,GIF-
// //参数三:图片输出到哪里去-
// ImageIO.write(image,"PNG",response.getOutputStream());
// }
// /**
// * 产生4位随机字符串 -
// */
// private String getCheckCode() {
// String base = "23456789ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz";
// int size = base.length();
// Random r = new Random();
// StringBuffer sb = new StringBuffer();
// for(int i=1;i<=4;i++){
// //产生0到size-1的随机值-
// int index = r.nextInt(size);
// //在base字符串中获取下标为index的字符-
// char c = base.charAt(index);
// //将c放入到StringBuffer中去-
// sb.append(c);
// }
// return sb.toString();
// }
// public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// this.doGet(request,response);
// }
//}

Loading…
Cancel
Save