• 大小: 2.98MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-20
  • 语言: Java
  • 标签: Java  Servlet  

资源简介

【Java】学生管理系统——Servlet实现,代码和数据库(源代码下载) 文章链接:https://blog.csdn.net/linghugoolge/article/details/102778180

资源截图

代码片段和文件信息

package Controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Dao.AdministratorDao;
import Dao.ClassesDao;
import Dao.CourseDao;
import Dao.GradeDao;
import Dao.StudentDao;
import Model.Administrator;
import Model.Classes;
import Model.Course;
import Model.Grade;
import Model.Student;

/**
 * Servlet implementation class AddScoreServlet
 */
public class AddScoreServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
request.setCharacterEncoding(“UTF-8“);
response.setContentType(“text/html;charset=utf-8“);

String stuId = request.getParameter(“stuId“);
String stuName = request.getParameter(“stuName“);
String courseId = request.getParameter(“courseId“);
String tcId = request.getParameter(“tcId“);
String courseGrade = request.getParameter(“courseGrade“);
String classId = request.getParameter(“classId“);

try{
StudentDao stuDao = new StudentDao();
CourseDao courseDao = new CourseDao();
AdministratorDao adminDao = new AdministratorDao();
ClassesDao classesDao = new ClassesDao();
GradeDao gradeDao = new GradeDao();

Student stu = stuDao.find(stuId);
Course course = courseDao.find(courseId);
Administrator admin = adminDao.find(tcId);
Classes classes = classesDao.find(classId);
Grade grade = new Grade();

grade.setStuId(stuId);
grade.setStuName(stuName);
grade.setCourseId(courseId);
grade.setTcId(tcId);
grade.setCourseGrade(courseGrade);
grade.setClassId(classId);
if (stu.getStuName() == null) {
request.setAttribute(“errerMsg“ “姓名为空“);
request.getRequestDispatcher(“/Jsp/AddScore.jsp“).forward(request response);
}
if(stu != null || stu.getStuName() == stuName){
if(course != null){
if(admin != null){
if(classes != null){
if(gradeDao.insert(grade)){
response.sendRedirect(request.getContextPath() + “/Jsp/AddScore.jsp“);
}else{
request.setAttribute(“errerMsg“ “添加失败“);
request.getRequestDispatcher(“/Jsp/AddScore.jsp“).forward(request response);
}
}else{
request.setAttribute(“errerMsg“ “没有该班级“);
request.getRequestDispatcher(“/Jsp/AddScore.jsp“).forward(request response);
}
}else{
request.setAttribute(“errerMsg“ “没有该教师ID“);
request.getRequestDispatcher(“/Jsp/AddScore.jsp“).forward(request response);
}
} else {
request.setAttribute(“errerMsg“ “没有该课程ID“);
request.getRequestDispatcher(“/Jsp/AddScore.jsp“).forward(request response);
}

} catch (Exception ee) {
ee.printStackTrace();
}
}

protected void doPost(HttpServletRequest request H

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-10-29 10:13  TestJavaWeb\
     目录           0  2019-10-29 10:13  TestJavaWeb\.idea\
     目录           0  2019-10-29 10:13  TestJavaWeb\.idea\artifacts\
     文件         519  2019-10-23 18:41  TestJavaWeb\.idea\artifacts\TestJavaWeb_war_exploded.xml
     文件        1043  2019-10-23 21:00  TestJavaWeb\.idea\encodings.xml
     目录           0  2019-10-29 10:13  TestJavaWeb\.idea\libraries\
     文件         660  2019-10-23 20:18  TestJavaWeb\.idea\libraries\commons_beanutils_1_9_3.xml
     文件         290  2019-10-23 18:48  TestJavaWeb\.idea\libraries\lib.xml
     文件         276  2019-10-23 18:41  TestJavaWeb\.idea\misc.xml
     文件         269  2019-10-23 18:41  TestJavaWeb\.idea\modules.xml
     文件        6614  2019-10-29 10:11  TestJavaWeb\.idea\workspace.xml
     文件        1070  2019-10-23 20:21  TestJavaWeb\TestJavaWeb.iml
     目录           0  2019-10-29 10:13  TestJavaWeb\src\
     目录           0  2019-10-29 10:13  TestJavaWeb\src\Controller\
     文件        3130  2019-01-06 15:04  TestJavaWeb\src\Controller\AddScoreServlet.java
     文件        2508  2019-01-08 19:54  TestJavaWeb\src\Controller\AutoLoginFilter.java
     文件        3299  2019-10-29 09:33  TestJavaWeb\src\Controller\CheckServlet.java
     文件        2557  2019-01-06 14:34  TestJavaWeb\src\Controller\DelScoreServlet.java
     文件        1257  2019-01-06 14:34  TestJavaWeb\src\Controller\ExitServlet.java
     文件        2179  2019-01-08 19:48  TestJavaWeb\src\Controller\FindScoreServlet.java
     文件        4820  2019-10-29 09:40  TestJavaWeb\src\Controller\LoginServlet.java
     文件        1214  2019-01-06 14:34  TestJavaWeb\src\Controller\LogoutServlet.java
     文件        2003  2019-01-06 14:34  TestJavaWeb\src\Controller\UpdScoreServlet.java
     目录           0  2019-10-29 10:13  TestJavaWeb\src\Dao\
     文件        3841  2019-01-04 16:23  TestJavaWeb\src\Dao\AdministratorDao.java
     文件        3409  2019-01-06 15:04  TestJavaWeb\src\Dao\ClassesDao.java
     文件        3615  2019-01-04 16:25  TestJavaWeb\src\Dao\CourseDao.java
     文件        4269  2019-01-05 17:57  TestJavaWeb\src\Dao\GradeDao.java
     文件        3830  2019-01-04 16:24  TestJavaWeb\src\Dao\StudentDao.java
     文件         898  2019-01-04 17:26  TestJavaWeb\src\Dao\UserDao.java
     目录           0  2019-10-29 10:13  TestJavaWeb\src\Model\
............此处省略35个文件信息

评论

共有 条评论