Java项目:SSM学生选课管理系统

news2024/9/20 20:26:06

作者主页:源码空间站2022

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

由SpringMVC+MyBatis为主要框架,mysql8.0配置主从复制实现读写分离。前端主要由bootstrap完成,背景用particles.js插件。数据库交互查询用到pagehelper分页。在添加修改相关功能时通过ajax来验证其主键是否存在可用。代码层次清晰,输入框约束较高,已配置登录拦截。

项目主要分为管理员、教师、学生三种角色;

管理员角色包含以下功能:

管理员登录,学生管理,教师管理,课程管理等功能。

教师角色包含以下功能:
登录界面,查看课程,建立课程计划,管理教学课程,成绩查询结课等功能。

学生角色包含以下功能:

登录界面,选课,确认选课,查看选课结果,退选界面,查看已修课程,管理个人信息等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 

5.数据库:MySql 5.7版本;

6.是否Maven项目:是;

技术栈

1. 后端:Spring+SpringMVC+Mybatis

2. 前端:JavaScript、jQuery、bootstrap4、particles.js、ajax

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中applicationContext.xml配置文件中的数据库配置改为自己的配置;注:因为此处为读写分离的,需要配置2处;
4. 运行项目,输入localhost:8080/ 登录
管理员账号/密码:admin/admin
教师账号/密码: 0002/123456

学生账号/密码:201507021227/123456

运行截图

管理员角色

学生管理

 

教师角色

 

相关代码

AdminHandler

package net.fuzui.StudentInfo.handler;

import net.fuzui.StudentInfo.pojo.Student;
import net.fuzui.StudentInfo.pojo.Teacher;
import net.fuzui.StudentInfo.service.AdminService;
import net.fuzui.StudentInfo.service.CoursePlanService;
import net.fuzui.StudentInfo.service.CourseService;
import net.fuzui.StudentInfo.service.SelectCourseService;
import net.fuzui.StudentInfo.service.StudentService;
import net.fuzui.StudentInfo.service.TeacherService;
import net.fuzui.StudentInfo.service.impl.AdminServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/AdminHandler")
//@SessionAttributes("studentList")
//@SessionAttributes("teacherList")
public class AdminHandler {


    @Autowired
	StudentService studentService;
	@Autowired
	TeacherService teacherService;
	@Autowired
	CoursePlanService coursePlanService;
	@Autowired
    CourseService courseService;
	@Autowired
	SelectCourseService selectCourseService;


	/**
	 * JavaScript学的不好,目前只能通过这种方式把三级联动下拉列表的val改变为以下值传给数据库。
	 * 
	 */
	String[] arr_belongcoll = {"计算机学院","建筑学院","外国语学院","人文学院"};
	String[][] arr_belongpro = {
                    {"网络工程","软件工程","物联网","信息管理"},
                    {"土木工程","测绘工程","工程造价", "城市规划"},
                    {"英语", "日语", "俄语", "西班牙语"},
                    {"汉语言", "历史", "新闻", "网络新媒体"}
				};
	String[][][] arr_belongcla = {
                {
                    {"网络B151","网络B152","网络B161","网络B162","网络B171","网络B172"},
                    {"软件B151","软件B152","软件B161","软件B162","软件B171","软件B172"},
                    {"物联B151","物联B152","物联B161","物联B162","物联B171","物联B172"},
                    {"信管B151","信管B152","信管B161","信管B162","信管B171","信管B172"}
                    
                },
                {
                    {"土木B151","土木B152","土木B161","土木B162","土木B171","土木B172"},
                    {"测绘B151","测绘B152","测绘B161","测绘B162","测绘B171","测绘B172"},
                    {"造价B151","造价B152","造价B161","造价B162","造价B171","造价B172"},
                    {"规划B151","规划B152","规划B161","规划B162","规划B171","规划B172"}
                    
                },
                {
                    {"英语B151","英语B152","英语B161","英语B162","英语B171","英语B172"},
                    {"日语B151","日语B152","日语B161","日语B162","日语B171","日语B172"},
                    {"俄语B151","俄语B152","俄语B161","俄语B162","俄语B171","俄语B172"},
                    {"牙语B151","牙语B152","牙语B161","牙语B162","牙语B171","牙语B172"}
                    
				},
                {
                    {"汉语B151","汉语B152","汉语B161","汉语B162","汉语B171","汉语B172"},
                    {"历史B151","历史B152","历史B161","历史B162","历史B171","历史B172"},
                    {"新闻B151","新闻B152","新闻B161","新闻B162","新闻B171","新闻B172"},
                    {"网媒B151","网媒B152","网媒B161","网媒B162","网媒B171","网媒B172"}
                    
				}
		};

 // 添加
 	@RequestMapping("/addStudent")
 	public String addStudent(Student student, Model model) {
 		
 		
 		
 		
 		int col = Integer.parseInt(student.getCollege());
 		int pro = Integer.parseInt(student.getProfession());
 		int cla = Integer.parseInt(student.getClassr());
 		//总感觉前端js写的有问题。
 		student.setCollege(arr_belongcoll[pro]);
 		student.setProfession(arr_belongpro[pro][col]);
 		student.setClassr(arr_belongcla[pro][col][cla]);
 		
 		
 		
 		if (studentService.insertStudent(student) != 0) {
 			model.addAttribute("student", student);
 			return "success";
 			// return "admin/addStudent";
 		} else {
 			return "fail";
 		}

 	}
 	//查询全部学生方法
 	public void queryStu(HttpServletRequest request) {
 		List<Student> studentList = new ArrayList<Student>();
 		studentList = studentService.selectStudentBySql(1,10);
 		
 		
 		request.setAttribute("slist", studentList);
 	}

 	public void pageIn(Model model,List list) {
 		PageInfo page = new PageInfo(list, 5);
	 	model.addAttribute("pageInfo", page);
 	}
 	
 	// 查询
 	@RequestMapping(value = "/query/{pn}", method = RequestMethod.GET)
 	public String redirect(@RequestParam("serc") String serc, @RequestParam("condition") String condition,HttpServletRequest request,
 			@PathVariable(value = "pn") String pn,Model model) {

 		int no = Integer.parseInt(pn);
// 		System.out.println("-----"+no+"----");
 		List<Student> studentList = new ArrayList<Student>();
 		PageHelper.startPage(no, 5);
 		request.setAttribute("serc", serc);
		request.setAttribute("condition", condition);
 		//查询全部
 		if (serc.equals("all")) {
 			
 			
 			
 	 		
 			System.out.println("------------------------------------------------------------------------------------------------");
// 			studentList = studentService.selectStudentBySql(1,10);
// 			//model.addAttribute("studentList", studentList);
// 			request.setAttribute("slist", studentList);
// 			System.out.println("00000"+request.getAttribute("slist"));
// 			System.out.println(studentList);
 			studentList = studentService.selectStudentBySql(1,10);
 			pageIn(model, studentList);
 	 		request.setAttribute("slist", studentList);
 			return "admin/queryStudent";

 		//根据学号查询
 		} else if (serc.equals("sid")) {

 			studentList = studentService.getByStudentSid(1,10,condition);
 			pageIn(model, studentList);
 			request.setAttribute("slist", studentList);
 			System.out.println("sid");

 			return "admin/queryStudent";

 		//根据学院查询
 		} else if (serc.equals("col")) {
 			
 			
 			studentList = studentService.getByStudentCol(1,10,condition);
 			pageIn(model, studentList);
 			request.setAttribute("slist", studentList);
 			System.out.println(studentList);
 			System.out.println("col");
 			return "admin/queryStudent";

 		//根据专业查询
 		} else if (serc.equals("pro")) {
 			studentList = studentService.getByStudentPro(1,10,condition);
 			pageIn(model, studentList);
 			request.setAttribute("slist", studentList);
 			System.out.println(studentList);
 			System.out.println("pro");
 			return "admin/queryStudent";

 		//根据班级查询
 		} else if (serc.equals("cla")) {
 			studentList = studentService.getByStudentCla(1,10,condition);
 			pageIn(model, studentList);
 			//model.addAttribute("studentList", studentList);
 			request.setAttribute("slist", studentList);
// 			System.out.println(studentList);
// 			System.out.println("cla");
 			return "admin/queryStudent";

 		} else {

// 			studentList = studentService.selectStudentBySql(1,10);
// 			model.addAttribute("studentList", studentList);
// 			request.setAttribute("slist", studentList);
// 			System.out.println("00000"+request.getAttribute("slist"));
// 			System.out.println(studentList);
 			studentList = studentService.selectStudentBySql(1,10);
 			pageIn(model, studentList);
 	 		request.setAttribute("slist", studentList);
 			return "admin/queryStudent";

 		}

 	}

 	// 删除学生
 	@RequestMapping(value = "/delete/{sid}", method = RequestMethod.GET)
 	public String deleteStudent(@PathVariable(value = "sid") String sid, Model model) {


 		if (studentService.deleteStudent(sid) != 0) {
 			System.out.println("success");
 			
 			return "success";
 		} else {
 			System.out.println("fail");
 			return "fail";
 		}

 	}

 	// 跳转页面
 	@RequestMapping(value = "/finalPage", method = RequestMethod.GET)
 	public String finalPage(HttpServletRequest request) {
 		queryStu(request);
 		return "admin/queryStudent";
 	}

 	// 修改定位
 	@RequestMapping(value = "/moditystu/{sid}", method = RequestMethod.GET)
 	public String editPre(@PathVariable("sid") String sid, HttpServletRequest request) {

 		List<Student> studentList = new ArrayList<Student>();
 		studentList = studentService.getByStudentSid(1,10,sid);
 		
 		request.setAttribute("studentList", studentList);
 		System.out.println("-----进入修改");
 		return "admin/modiStudent";
 	}

 	
 	
 	// 修改
 	@RequestMapping(value = "/moditystud/{sid}", method = RequestMethod.GET)
 	public String update(@PathVariable("sid") String sid, Student student, HttpServletRequest request) {

 		int col = Integer.parseInt(student.getCollege());
 		int pro = Integer.parseInt(student.getProfession());
 		int cla = Integer.parseInt(student.getClassr());
 		//总感觉前端js写的有问题。
 		student.setCollege(arr_belongcoll[pro]);
 		student.setProfession(arr_belongpro[pro][col]);
 		student.setClassr(arr_belongcla[pro][col][cla]);
 		
 		if (studentService.modifyStudent(student) != 0) {
 			System.out.println("----修改成功--------------------------------------------------------------------------------------------------------");
 			return "success";
 		} else {
 			System.out.println("----修改失败----------------------------------------------------------------");
 			return "fail";
 		}
 	}
 	
 	
 	

 	// 跳转页面
 	@RequestMapping("/managestu/{pn}")
 	public String manageStudent(HttpServletRequest request,
 			@PathVariable(value = "pn") String pn,Model model) {
 		int no = Integer.parseInt(pn);
 		
 		PageHelper.startPage(no, 5);
 		List<Student> studentList = new ArrayList<Student>();
 		studentList = studentService.selectStudentBySql(1,100);
 		pageIn(model, studentList);
 		request.setAttribute("slist", studentList);
 		return "admin/queryStudent";
 	}
 		
 	// 跳转页面
 	@RequestMapping("/managetea/{pn}")
 	public String manageTeacher(HttpServletRequest request,
 			@PathVariable(value = "pn") String pn,Model model) {
 		int no = Integer.parseInt(pn);
 		PageHelper.startPage(no, 5);
 		List<Teacher> teacherList = new ArrayList<Teacher>();
	 	teacherList = teacherService.selectTeacherBySql(1,10);
	 	pageIn(model, teacherList);
	 	request.setAttribute("teacherList", teacherList);
 		return "admin/queryTeacher";
 	}


 	// 跳转页面
 	@RequestMapping("/addstu")
 	public String adStudent() {
 		return "admin/addStudent";
 	}

 	// 跳转页面
 	@RequestMapping("/addtea")
 	public String adTeacher() {
 		return "admin/addTeacher";
 	}

 	// 跳转页面
 	@RequestMapping("/addcou")
 	public String adCourse() {
 		return "admin/addCourse";
 	}
 	
 // 添加
 	@RequestMapping("/addTeacher")
 	public String addTeacher(Teacher teacher, Model model, HttpSession httpSession) {

 		if (teacherService.insertTeacher(teacher) != 0) {
 			model.addAttribute("teacher", teacher);

 			//---------------------------------待优化-----同样不能实时刷新--------------------------------------------
 			return "success";
 			//return new ModelAndView(new RedirectView("/StudentInfo/TeacherHandler/finalPage"));
 			// return "techer/teacherFace";
 		} else {
 			return "fail";
 			//return new ModelAndView(new RedirectView("fail"));
 		}

 	}

 	
 	/**
 	 * 教师相关
 	 */
 	
 	//查询全部教师方法
 	 	public void queryTea(HttpServletRequest request) {
 	 		List<Teacher> teacherList = new ArrayList<Teacher>();
 	 		teacherList = teacherService.selectTeacherBySql(1,10);
 	 		request.setAttribute("teacherList", teacherList);
 	 	}
 	
 	// 查询
 	@RequestMapping(value = "/queryTea/{pn}", method = RequestMethod.GET)
 	public String redirectTea(@RequestParam("serc") String serc, @RequestParam("condition") String condition,HttpServletRequest request,
 			@PathVariable(value = "pn") String pn,Model model) {
 		int no = Integer.parseInt(pn);
 		PageHelper.startPage(no, 5);
 		List<Teacher> teacherList = new ArrayList<Teacher>();
 		request.setAttribute("serc", serc);
		request.setAttribute("condition", condition);
 		
 		if (serc.equals("all")) {

 			teacherList = teacherService.selectTeacherBySql(1,10);
 			pageIn(model, teacherList);
 	 		request.setAttribute("teacherList", teacherList);
 			return "admin/queryTeacher";

 		} else if (serc.equals("tid")) {

 			teacherList = teacherService.getByTeacherTid(1,10,condition);
 			pageIn(model, teacherList);
 			request.setAttribute("teacherList", teacherList);
 			System.out.println("tid");

 			return "admin/queryTeacher";

 		} else {

 			teacherList = teacherService.selectTeacherBySql(1,10);
 			pageIn(model, teacherList);
 	 		request.setAttribute("teacherList", teacherList);
 			return "admin/queryTeacher";

 		}

 	}
 	
 	

 	//删除教师
 	@RequestMapping(value = "/deleteTea/{tid}", method = RequestMethod.GET)
 	public String deleteTeacher(@PathVariable(value = "tid") String tid, Model model) {


 		if (teacherService.deleteTeacher(tid) != 0) {
 			System.out.println("success");
 //------------------------代优化,现状:删除后需要手动刷新界面或者重新查询,不能实时刷新。---------------------------------------------------
 			return "success";
 		} else {
 			System.out.println("fail");
 			return "fail";
 			
 		}

 	}

 	@RequestMapping(value = "/finalPageTea", method = RequestMethod.GET)
 	public String finalPageTea(HttpServletRequest request) {
 		queryTea(request);
 		return "admin/queryTeacher";
 	}

 	//修改定位,可优化
 	@RequestMapping(value = "/modityTea/{tid}", method = RequestMethod.GET)
 	public String editPreTea(@PathVariable("tid") String tid, HttpServletRequest request) {

 		List<Teacher> teacherList = new ArrayList<Teacher>();
 		teacherList = teacherService.getByTeacherTid(1,10,tid);
 		//model.addAttribute("teacherList", teacherList);
 		request.setAttribute("teacherList", teacherList);

 		return "admin/modiTeacher";
 	}

 	// 修改
 	@RequestMapping(value = "/modityTeac/{tid}", method = RequestMethod.GET)
 	public String update(@PathVariable("tid") String tid, Teacher teacher, HttpServletRequest request) {

 		if (teacherService.modifyTeacher(teacher) != 0) {
 			return "success";
 		} else {
 			return "fail";
 		}
 	}
    
    
}

AjaxHandler

package net.fuzui.StudentInfo.handler;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import net.fuzui.StudentInfo.service.CoursePlanService;
import net.fuzui.StudentInfo.service.CourseService;
import net.fuzui.StudentInfo.service.StudentService;
import net.fuzui.StudentInfo.service.TeacherService;

@Controller
@RequestMapping("/AjaxHandler")
public class AjaxHandler {
	@Autowired
    CourseService courseService;
	@Autowired
	StudentService studentService;
	@Autowired
	TeacherService teacherService;
	@Autowired
	CoursePlanService coursePlanService;
	
	/**
	 * ajax验证课程编号是否存在
	 * @param cid
	 * @param response
	 * @param request
	 * @throws IOException
	 */
	@RequestMapping(value="/existCid",method = RequestMethod.POST)
	public void existCid(@RequestParam("cid") String cid,HttpServletResponse response,HttpServletRequest request) throws IOException{
		System.out.println("课程编号="+cid);
 
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		System.out.println(cid+"----------");
		PrintWriter out=null;
		
		out=response.getWriter();
		if(courseService.getByCouCid(cid) != null && cid !=null && !"".equals(cid)){
			out.println("课程编号已存在");
		}else if(cid !=null && !"".equals(cid)){
			out.println("此课程编号可以使用");
		}else {
			out.println("课程编号不能为空");
		}
		out.flush();
		out.close();
		
	}
	
	@RequestMapping(value="/existSid",method = RequestMethod.POST)
	public void existSid(@RequestParam("sid") String sid,HttpServletResponse response,HttpServletRequest request) throws IOException{
		System.out.println("学号="+sid);
 
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out=null;
		
		out=response.getWriter();
		if(studentService.getByStuSid(sid) != null && sid.length() ==12){
			out.println("学号已存在");
		}else if(sid.length() ==12){
			out.println("学号可以使用");
		}else {
			out.println("学号必须是12位");
		}
		out.flush();
		out.close();
		
	}
	//ajax验证教师id
	@RequestMapping(value="/existTid",method = RequestMethod.POST)
	public void existTid(@RequestParam("tid") String tid,HttpServletResponse response,HttpServletRequest request) throws IOException{
 
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out=null;
		
		out=response.getWriter();
		if(teacherService.getByTeaTid(tid) != null && tid.length() <=5){
			out.println("教师编号已存在");
		}else if(tid.length() <=12){
			out.println("教师编号可以使用");
		}else {
			out.println("教师编号必须小于等于5位");
		}
		out.flush();
		out.close();
		
	}

	
	@RequestMapping(value="/existTime",method = RequestMethod.POST)
	public void existTime(@RequestParam("coursetime") String coursetime,@RequestParam("courseweek") String courseweek,
			@RequestParam("classroom") String classroom,HttpServletResponse response,HttpServletRequest request) throws IOException{
 
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out=null;
		System.out.println("--------------------------");
		System.out.println(coursetime+"---"+courseweek+"---"+classroom);
		out=response.getWriter();
		if(coursePlanService.ajaxGetCoursePlan(coursetime,courseweek,classroom) != null){
			out.println("此功能排重正在开发中.....");
		}else {
			out.println("此功能排重正在开发中.....");
		}
		out.flush();
		out.close();
		
	}
	
}

CourseHandler

package net.fuzui.StudentInfo.handler;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import net.fuzui.StudentInfo.pojo.Course;
import net.fuzui.StudentInfo.pojo.Teacher;
import net.fuzui.StudentInfo.service.CourseService;

@Controller
@RequestMapping("/CourseHandler")
@SessionAttributes("courseList")
public class CourseHandler {
	@Autowired
    CourseService courseService;

	// 添加课程
	@RequestMapping("/addCourse")
	public String addCourse(Course course, Model model) {
		

		if (courseService.insertCourse(course) != 0) {
			model.addAttribute("course", course);
			return "success";
		} else {
			return "fail";
		}
	}

	public void pageIn(Model model,List list) {
 		PageInfo page = new PageInfo(list, 5);
	 	model.addAttribute("pageInfo", page);
 	}
	
	public void queryCou(HttpServletRequest request) {
		List<Course> courseList = new ArrayList<Course>();
	 	courseList = courseService.selectCourseBySql(1,10);
	 	request.setAttribute("courseList", courseList);
	}

	// 查询课程
	@RequestMapping(value = "/query/{pn}", method = RequestMethod.GET)
	public String redirect(@RequestParam("serc") String serc, @RequestParam("condition") String condition,
			HttpServletRequest request,@PathVariable(value = "pn") String pn,Model model) {

		int no = Integer.parseInt(pn);
		List<Course> courseList = new ArrayList<Course>();
		PageHelper.startPage(no, 5);
		request.setAttribute("serc", serc);
		request.setAttribute("condition", condition);
		
		
		if (serc.equals("all")) {

	
		 	courseList = courseService.selectCourseBySql(1,10);
		 	pageIn(model, courseList);
		 	request.setAttribute("courseList", courseList);
			System.out.println(courseList);
			return "admin/queryCourse";

		} else if (serc.equals("sid")) {

			courseList = courseService.getByCourseCid(1,10,condition);
			pageIn(model, courseList);
			request.setAttribute("courseList", courseList);
			System.out.println("sid");

			return "admin/queryCourse";

		} else if (serc.equals("nam")) {
			courseList = courseService.getByCourseCname(1,10,condition);
			pageIn(model, courseList);
			request.setAttribute("courseList", courseList);
			System.out.println(courseList);
			System.out.println("cla");
			return "admin/queryCourse";

		} else if (serc.equals("col")) {
			courseList = courseService.getByCourseCol(1,10,condition);
			pageIn(model, courseList);
			request.setAttribute("courseList", courseList);
			System.out.println(courseList);
			System.out.println("col");
			return "admin/queryCourse";

		} else if (serc.equals("type")) {
			courseList = courseService.getByCourseType(1,10,condition);
			pageIn(model, courseList);
			request.setAttribute("courseList", courseList);
			System.out.println(courseList);
			System.out.println("pro");
			return "admin/queryCourse";

		} else {

			courseList = courseService.selectCourseBySql(1,10);
		 	pageIn(model, courseList);
		 	request.setAttribute("courseList", courseList);
			return "admin/queryCourse";

		}

	}

	//删除学生
	@RequestMapping(value = "/delete/{cid}", method = RequestMethod.GET)
	public String deleteStudent(@PathVariable(value = "cid") String cid, HttpServletRequest request) {


		if (courseService.deleteCourse(cid) != 0) {
			System.out.println("success");
			queryCou(request);
			return "success";
		} else {
			System.out.println("fail");
			return "fail";
		}

	}

	//跳转到queryCourse页面
	@RequestMapping(value = "/finalPage", method = RequestMethod.GET)
	public String finalPage(HttpSession httpSession,HttpServletRequest request) {
		Object admin = request.getSession().getAttribute("courseList");
 		System.out.println(admin+"111111111111111111111111111111111111111111111111111111111111111111111111111");
		return "admin/queryCourse";
	}

	/**
	 * 	修改课程定位
	 * @param cid
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/moditystu/{cid}", method = RequestMethod.GET)
	public String editPre(@PathVariable("cid") String cid, HttpServletRequest request) {

		
		List<Course> courseList = new ArrayList<Course>();
		courseList = courseService.getByCourseCid(1,10,cid);
		request.setAttribute("courseList", courseList);

		return "admin/modiCourse";
	}

	//修改课程信息
	@RequestMapping(value = "/moditystud/{cid}", method = RequestMethod.GET)
	public String update(@PathVariable("cid") String cid, Course course, Model model) {
		
		if (courseService.modifyCourse(course) != 0) {
			return "success";
		} else {
			return "fail";
		}
	}

	
	//跳转到queryCourse页面
	@RequestMapping("/managecou/{pn}")
	public String manageCourse(HttpServletRequest request,@PathVariable(value = "pn") String pn,Model model) {
		int no = Integer.parseInt(pn);
		List<Course> courseList = new ArrayList<Course>();
		PageHelper.startPage(no, 5);
		courseList = courseService.selectCourseBySql(1,10);
	 	pageIn(model, courseList);
	 	request.setAttribute("courseList", courseList);
		return "admin/queryCourse";
	}
}

如果也想学习本系统,下面领取。关注并回复:099ssm  

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/64708.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Spring Boot整合JWT实现用户认证

初探JWT 什么是JWT JWT(Json Web Token)&#xff0c;是一种工具&#xff0c;格式为XXXX.XXXX.XXXX的字符串&#xff0c;JWT以一种安全的方式在用户和服务器之间传递存放在JWT中的不敏感信息。 为什么要用JWT 设想这样一个场景&#xff0c;在我们登录一个网站之后&#xff0…

[Cortex-M3]-2-map文件解析

目录 1 几个问题 1.1 什么是map文件 1.2 如何查看编译出的程序和数据的信息 1.3 如何生成map文件 1.4 map文件里面有哪些信息 2 map文件信息详解 2.1 Section Cross References 2.2 Removing Unused input…

15年磨一剑,亚马逊云科技数据产品掌门人 Swami 揭秘云原生数据战略的三大关键要素

2022亚马逊云科技 re:Invent 全球大会正在拉斯维加斯如火如荼进行中&#xff0c;亚马逊云科技数据与机器学习副总裁 Swami Sivasubramanian 博士发表了“数据与机器学习如何助力企业构建端到端的数据战略”的主题演讲来开启第三天的日程。 Swami 博士重点介绍了亚马逊云科技在…

玉米脱粒机设计全套

目 录 摘要 I Abstract II 1引言 1 1.1 课题的来源与研究的目的和意义 1 1.2 本课题研究的内容 3 2玉米脱粒机总体结构的设计 5 2.1 玉米脱粒机工作方式的选择 7 2.2 玉米脱粒机的结构原理 10 2.3 机械传动部分的设计计算 11 2.3.1电机的选型计算 12 2.3.2 V带传动的设计计算 1…

C语言:文件操作(2)

文件的打开和关闭 文件在读写之前应该先打开文件&#xff0c;在使用结束之后应该关闭文件。 在编写程序的时候&#xff0c;在打开文件的同时&#xff0c;都会返回一个FILE*的指针变量指向该文件&#xff0c;也相当于建立了指针和文件的关系。 ANSIC规定使用fopen函数来打开文…

(十五) 共享模型之工具【线程池】

一、自定义线程池 1. 简易线程池 Slf4j(topic "c.TestPool") public class TestPool {public static void main(String[] args) {ThreadPool threadPool new ThreadPool(2,1000, TimeUnit.MILLISECONDS, 10);for (int i 0; i < 5; i) {int j i;threadPool.exe…

博球一看,记录疯狂!我与世界杯的那些二三事

文章目录 &#x1f525;关于世界杯 &#x1f525;关于2022卡塔尔世界杯 &#x1f525;我与足球 &#x1f525;我与世界杯 ⚽分享一颗足球 ⚽实现效果 &#x1f525;关于世界杯 大力神杯 国际足联世界杯&#xff08;FIFA World Cup&#xff09;&#xff0c;简称“世界杯”…

Vue中的数据代理与数据劫持

数据代理 数据代理字面上是通过一个对象代理对另一个对象属性的操作在vue中的数据代理&#xff0c;实际上是通过vm上的属性代理对_data中属性的操作 数据劫持 数据劫持也可称作数据代理&#xff0c;字面上是劫持到某个属性的变化&#xff0c;去做其他的操作在vue中的数据劫…

练习:查询学生新学期选课(python之str、dict、list试炼)

查询学生新学期选课(python之str、dict、list试炼)&#xff0c;数据用字典、列表存储。考验字符串的各种转换&#xff0c;字典、列表的读写。 (本文获得CSDN质量评分【88】)【学习的细节是欢悦的历程】Python 官网&#xff1a;https://www.python.org/ Free&#xff1a;大咖免…

【Git 教程系列第 26 篇】Mac 升级系统到 Ventura 后,Git 公钥报 Permission denied 错误问题的解决方案

这是【Git 教程系列第 26 篇】&#xff0c;如果觉得有用的话&#xff0c;欢迎关注专栏。 注&#xff1a; 如果你是因为升级系统到 Ventura 后遇到的这个问题&#xff0c;可以直接看第三步的解决方案&#xff0c;前两步是我自己的写作习惯&#xff0c;只是记录一下这个过程&…

Qt OpenGL 图形字体的纹理映射

这次教程中&#xff0c;我们将在第14课的基础上创建带有纹理的字体&#xff0c;它真的很简单。也许你想知道如何才能给字体赋予纹理贴图&#xff1f;我们可以使用自动纹理坐标生成器&#xff0c;它会自动为字体上的每一个多边形生成纹理坐标。 这次课中我们还将使用Wingdings字…

BNext

又搬来了大神器啊 来自德国HassoPlattner计算机系统工程研究院的NianhuiGuo和HaojinYang等研究者提出了BNext模型&#xff0c;成为第一个在ImageNet数据集上top1分类准确率突破80%的BNN。 两年前&#xff0c;依靠早期 BNN 工作 XNOR-Net 起家的 XNOR.AI 被苹果公司收购&#…

redis基础5——redis的频道订阅和模式频道、redis主从复制、哨兵集群

文章目录一、发布订阅1.1 发布订阅过程1.2 发布订阅类型1.2.1 频道的发布订阅1.2.1.1 订阅频道* 实现原理1.2.1.2 发送消息* 实现原理1.2.1.3 退订频道* 实现原理1.2.2 模式的发布订阅1.2.2.1 订阅模式频道* 实现原理1.2.2.2 查询订阅与发布系统状态1.2.2.3 发送消息* 实现原理…

【c++基础】第三章 宏观部分:面向对象之类的层次结构与相互关系

第三章 宏观部分&#xff1a;面向对象之类的层次结构与相互关系关系has_a关系use_a关系&#xff08;友元关系&#xff09;is_a关系&#xff08;继承关系&#xff09;单继承多继承菱形继承多态&#xff08;polymorphic&#xff09;虚函数多态底层机制&#xff1a;虚函数、虚函数…

spring导入第三方资源

一、第三方资源配置管理 说明&#xff1a;以管理DataSource连接池对象为例讲解第三方资源配置管理 1 管理DataSource连接池对象 问题导入 配置数据库连接参数时&#xff0c;注入驱动类名是用driverClassName还是driver&#xff1f; 1.1 管理Druid连接池【重点】 数据库准备…

Android挂载系统分区执行mount和remount

第一种&#xff0c;通过adb挂载&#xff0c;需要root权限&#xff1b; adb root //adb 获取root权限&#xff1b; adb remount /system //从新挂载system目录或者说分区 第二种&#xff1a;通过Android下的Linux命令挂载&#xff0c;需要root权限&#xff1b; adb shell //…

【第八章 索引,索引结构,B-Tree,B+Tree,Hash,索引分类,聚集索引二级索引,索引语法】

第八章 索引&#xff0c;索引结构&#xff0c;B-Tree&#xff0c;BTree&#xff0c;Hash&#xff0c;索引分类&#xff0c;聚集索引&二级索引&#xff0c;索引语法 1.索引&#xff1a; ①索引&#xff08;index&#xff09;是帮助MySQL高效获取数据的数据结构(有序)。 ②特…

[附源码]Python计算机毕业设计Django社区人员信息管理系统设计与实现

项目运行 环境配置&#xff1a; Pychram社区版 python3.7.7 Mysql5.7 HBuilderXlist pipNavicat11Djangonodejs。 项目技术&#xff1a; django python Vue 等等组成&#xff0c;B/S模式 pychram管理等等。 环境需要 1.运行环境&#xff1a;最好是python3.7.7&#xff0c;…

Java学习笔记——StringBuilder

目录StringBuilder概述StringBuilder的构造方法StringBuilder常用的成员方法StringBuilder提高效率的原因String和StringBuilder之间的转换StringBuilder概述 StringBuilder是一个可变字符串类&#xff0c;我们可以把它看成一个容器。 作用&#xff1a;提高字符串的操作效率 …

HTML5期末作业:明星网站设计与实现——明星薛之谦介绍网页设计7个页面HTML+CSS+JavaScript

&#x1f389;精彩专栏推荐&#x1f447;&#x1f3fb;&#x1f447;&#x1f3fb;&#x1f447;&#x1f3fb; ✍️ 作者简介: 一个热爱把逻辑思维转变为代码的技术博主 &#x1f482; 作者主页: 【主页——&#x1f680;获取更多优质源码】 &#x1f393; web前端期末大作业…