基于javaweb和mysql的ssm学生成绩管理系统(java+ssm+jsp+mysql+layui)

私信源码获取及调试交流

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb的SSM学生成绩管理系统(java+ssm+jsp+mysql+layui)

管理员:

admin 123456

老师:

teacher1 123456

teacher2 123456

学生:

student1 123456

student2 123456

student3 123456

			return mav;
		}
		@RequestMapping("/updatestu")
		public ModelAndView updatestu(String id,Student student,Model model) {
			student.setId(Integer.parseInt(id));
			adminService.updatestu(student);
			ModelAndView mav = new ModelAndView("admin/stumanage");
			return mav;
		}
		@RequestMapping(value = "/mohuname",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
		@ResponseBody
		public String mohuname(HttpSession session) {
			@SuppressWarnings("unchecked")
			List<Student> list=(List<Student>) session.getAttribute("list");
			JSONObject jsonobj=new JSONObject();
			jsonobj.put("code", 0);
			jsonobj.put("msg", "成功");
			jsonobj.put("count",list.size());
			JSONArray jsonobj2=new JSONArray();
			JSONObject jsonobj3=new JSONObject();
		    for(Student student:list) {
		    	jsonobj3.put("id",student.getId());
		    	jsonobj3.put("username",student.getUsername());
		    	jsonobj3.put("password",student.getPassword());
		    	jsonobj3.put("stuclass",student.getStuclass());
		    	jsonobj3.put("stuname",student.getStuname());
		    	jsonobj3.put("stuno",student.getStuno());
		    	jsonobj2.add(jsonobj3);
		    }
		    jsonobj.put("data", jsonobj2);		
			return jsonobj.toString();
		}
	//老师
		@RequestMapping("/addtea")
		public ModelAndView addteacher(Teacher teacher,Model model) {
			adminService.addteacher(teacher);
			ModelAndView mav = new ModelAndView("admin/teamanage");
			return mav;
		}
		@RequestMapping(value = "/teamanage",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
		@ResponseBody
		public String teamanage(Model model) {
			List<Teacher> list=adminService.teamanage();
			JSONObject jsonobj=new JSONObject();
			jsonobj.put("code", 0);
			jsonobj.put("msg", "成功");
			jsonobj.put("count",list.size());
			JSONArray jsonobj2=new JSONArray();
			JSONObject jsonobj3=new JSONObject();
		    for(Teacher teacher:list) {

@Controller
public class AdminController {
	@Autowired
		private AdminService adminService;
	@RequestMapping("/welcome")
	public ModelAndView welcome(Model model) {
		ModelAndView mav = new ModelAndView("admin/welcome");
		return mav;
	}
	//学生
		//学生数据分页
		@RequestMapping(value = "/liststudent",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
		@ResponseBody
		public String liststudent(Page page) {
			List<Student> list=adminService.stumanage();
			page.caculatestart();
			List<Student> list2=adminService.liststudent(page);
			JSONObject jsonobj=new JSONObject();
			jsonobj.put("code", 0);
			jsonobj.put("msg", "成功");
			jsonobj.put("count",list.size());
			JSONArray jsonobj2=new JSONArray();
			JSONObject jsonobj3=new JSONObject();
		    for(Student student:list2) {
		    	jsonobj3.put("id",student.getId());
		    	jsonobj3.put("username",student.getUsername());
		    	jsonobj3.put("password",student.getPassword());
		    	jsonobj3.put("stuclass",student.getStuclass());
	@Autowired
	private AdminService adminService;
	@RequestMapping("/index")
	public ModelAndView index(Model model) {
		ModelAndView mav = new ModelAndView("index");
		return mav;
	}
	//学生
	@RequestMapping("/hrefaddstu")
	public ModelAndView addstu(Model model) {
		ModelAndView mav = new ModelAndView("admin/addstu");
		return mav;
	}
	@RequestMapping("/hrefmohuname")
	public ModelAndView hrefmohuname(String stuname,Model model,HttpSession session) {
		List<Student> list=adminService.selectbyname(stuname);
		session.setAttribute("list", list);
		ModelAndView mav = new ModelAndView("admin/mohuname");
		return mav;
	}
	@RequestMapping("/hrefxiustu")
	public String xiustu(String id,Model model) {
		Student student=adminService.selectone(id);
		model.addAttribute("student",student);
		return "admin/updatestu";
	}
	@RequestMapping("/hrefstumanage")
	public ModelAndView hrefstumanage(Model model) {
		ModelAndView mav = new ModelAndView("admin/stumanage");
		return mav;
	}
//老师
	@RequestMapping("/hrefaddtea")
	public ModelAndView hrefaddtea(Model model) {
		ModelAndView mav = new ModelAndView("admin/addtea");
		return mav;
	}
	@RequestMapping("/hrefteamanage")
	public ModelAndView hrefteamanage(Model model) {
		ModelAndView mav = new ModelAndView("admin/teamanage");
		return mav;
	}
	@RequestMapping("/hrefmohunametea")
	public ModelAndView hrefmohunametea(String teaname,Model model,HttpSession session) {
		List<Teacher> list=adminService.selectbynametea(teaname);
		session.setAttribute("tealist",list);
		ModelAndView mav = new ModelAndView("admin/mohuname2");
		return mav;
	}
	@RequestMapping("/hrefxiutea")
		    	jsonobj3.put("stuname",student.getStuname());
		    	jsonobj3.put("stuno",student.getStuno());
		    	jsonobj2.add(jsonobj3);
		    }
		    jsonobj.put("data", jsonobj2);		
			return jsonobj.toString();
		}
	//老师
		@RequestMapping("/addtea")
		public ModelAndView addteacher(Teacher teacher,Model model) {
			adminService.addteacher(teacher);
			ModelAndView mav = new ModelAndView("admin/teamanage");
			return mav;
		}
		@RequestMapping(value = "/teamanage",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
		@ResponseBody
		public String teamanage(Model model) {
			List<Teacher> list=adminService.teamanage();
			JSONObject jsonobj=new JSONObject();
			jsonobj.put("code", 0);
			jsonobj.put("msg", "成功");
			jsonobj.put("count",list.size());
			JSONArray jsonobj2=new JSONArray();
			JSONObject jsonobj3=new JSONObject();
		    for(Teacher teacher:list) {
		    	jsonobj3.put("id",teacher.getId());
		    	jsonobj3.put("username",teacher.getUsername());
		    	jsonobj3.put("password",teacher.getPassword());
		    	jsonobj3.put("teaname",teacher.getTeaname());
		    	jsonobj2.add(jsonobj3);
		    }
		    jsonobj.put("data", jsonobj2);		
			return jsonobj.toString();
		}
		@RequestMapping("/deltea")
		public ModelAndView deltea(String id,Model model) {
			adminService.delteacher(id);
			ModelAndView mav = new ModelAndView("admin/teamanage");
			return mav;
		}
		@RequestMapping("/updatetea")
		public ModelAndView updatetea(String id,Teacher teacher,Model model) {
			teacher.setId(Integer.parseInt(id));
		return mav;
	}
	//学生
		//学生数据分页
		@RequestMapping(value = "/liststudent",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
		@ResponseBody
		public String liststudent(Page page) {
			List<Student> list=adminService.stumanage();
			page.caculatestart();
			List<Student> list2=adminService.liststudent(page);
			JSONObject jsonobj=new JSONObject();
			jsonobj.put("code", 0);
			jsonobj.put("msg", "成功");
			jsonobj.put("count",list.size());
			JSONArray jsonobj2=new JSONArray();
			JSONObject jsonobj3=new JSONObject();
		    for(Student student:list2) {
		    	jsonobj3.put("id",student.getId());
		    	jsonobj3.put("username",student.getUsername());
		    	jsonobj3.put("password",student.getPassword());
		    	jsonobj3.put("stuclass",student.getStuclass());
		    	jsonobj3.put("stuname",student.getStuname());
		    	jsonobj3.put("stuno",student.getStuno());
		    	jsonobj2.add(jsonobj3);
		    }
		    jsonobj.put("data", jsonobj2);		
			return jsonobj.toString();
		}
		@RequestMapping("/addstudent")
		public ModelAndView addstu(Student student,Model model) {
			adminService.addStudent(student);
			ModelAndView mav = new ModelAndView("admin/stumanage");
			return mav;
		}
		@RequestMapping("/delstu")
		public ModelAndView delstu(String id,Model model) {
			adminService.delstudnet(id);
			ModelAndView mav = new ModelAndView("admin/stumanage");
			return mav;
		}
		@RequestMapping("/updatestu")
		public ModelAndView updatestu(String id,Student student,Model model) {
			student.setId(Integer.parseInt(id));
			adminService.updatestu(student);
			ModelAndView mav = new ModelAndView("admin/stumanage");
			return mav;
		}
		@RequestMapping(value = "/mohuname",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
		@ResponseBody
	public ModelAndView findCustomerById(String username,String password,String people,Model model,HttpSession session) {
		if("student".equals(people)) {
			Student student=new Student();
			student.setUsername(username);
			student.setPassword(password);
			Student student2=loginService.findStuTeachByUsername(student);
			if(student2!=null) {
				session.setAttribute("student", student2);
				ModelAndView mav = new ModelAndView("/student/indexs");
				return mav;
			}else {
				ModelAndView mav = new ModelAndView("error");
				return mav;
			}
		}else if("teacher".equals(people)){
			Teacher teacher=new Teacher();
			teacher.setUsername(username);
			teacher.setPassword(password);
			Teacher teacher2=loginService.findTeachByUsername(teacher);
			if(teacher2!=null) {
				session.setAttribute("teacher", teacher2);
				ModelAndView mav = new ModelAndView("/teacher/indext");
				return mav;
			}else {
				ModelAndView mav = new ModelAndView("error");
				return mav;
			}
		}else if("manage".equals(people)){
			Admin admin =new Admin();
			admin.setUsername(username);
			admin.setPassword(password);
			if(loginService.findAdminById(admin)!=null) {
				ModelAndView mav = new ModelAndView("/admin/index");
				return mav;
			}else {
				ModelAndView mav = new ModelAndView("error");
				return mav;
			}
		}
		ModelAndView mav = new ModelAndView("error");
		return mav;
	}

@Controller
public class AdminController {
	@Autowired
		private AdminService adminService;
	@RequestMapping("/welcome")
	public ModelAndView welcome(Model model) {
		ModelAndView mav = new ModelAndView("admin/welcome");
		return mav;
	}
	//学生
		//学生数据分页
		@RequestMapping(value = "/liststudent",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
		@ResponseBody
		public String liststudent(Page page) {
			List<Student> list=adminService.stumanage();
			page.caculatestart();
			List<Student> list2=adminService.liststudent(page);
			JSONObject jsonobj=new JSONObject();
			jsonobj.put("code", 0);
			jsonobj.put("msg", "成功");
			jsonobj.put("count",list.size());
			JSONArray jsonobj2=new JSONArray();
			JSONObject jsonobj3=new JSONObject();
		    for(Student student:list2) {
		    	jsonobj3.put("id",student.getId());
		    	jsonobj3.put("username",student.getUsername());
		    	jsonobj3.put("password",student.getPassword());
		    	jsonobj3.put("stuclass",student.getStuclass());
		    	jsonobj3.put("stuname",student.getStuname());
		    	jsonobj3.put("stuno",student.getStuno());
		    	jsonobj2.add(jsonobj3);
		    }
		    jsonobj.put("data", jsonobj2);		
			return jsonobj.toString();
		}
				ModelAndView mav = new ModelAndView("error");
				return mav;
			}
		}else if("teacher".equals(people)){
			Teacher teacher=new Teacher();
			teacher.setUsername(username);
			teacher.setPassword(password);
			Teacher teacher2=loginService.findTeachByUsername(teacher);
			if(teacher2!=null) {
				session.setAttribute("teacher", teacher2);
				ModelAndView mav = new ModelAndView("/teacher/indext");
				return mav;
			}else {
				ModelAndView mav = new ModelAndView("error");
				return mav;
			}
		}else if("manage".equals(people)){
			Admin admin =new Admin();
			admin.setUsername(username);
			admin.setPassword(password);
			if(loginService.findAdminById(admin)!=null) {
				ModelAndView mav = new ModelAndView("/admin/index");
				return mav;
			}else {
				ModelAndView mav = new ModelAndView("error");
				return mav;
			}
		}
		ModelAndView mav = new ModelAndView("error");
		return mav;
	}
	@RequestMapping("/out")
	public ModelAndView out(HttpServletResponse response,HttpSession session,Model model) {
		ModelAndView mav = new ModelAndView("index");
		return mav;
	}
}

@Controller
}

@Controller
public class LoginController {
	@Autowired
	private LoginService loginService;	
	@RequestMapping("/login")
	public ModelAndView findCustomerById(String username,String password,String people,Model model,HttpSession session) {
		if("student".equals(people)) {
			Student student=new Student();
			student.setUsername(username);
			student.setPassword(password);
			Student student2=loginService.findStuTeachByUsername(student);
			if(student2!=null) {
				session.setAttribute("student", student2);
				ModelAndView mav = new ModelAndView("/student/indexs");
				return mav;
			}else {
				ModelAndView mav = new ModelAndView("error");
				return mav;
			}
		}else if("teacher".equals(people)){
			Teacher teacher=new Teacher();
			teacher.setUsername(username);
			teacher.setPassword(password);
			Teacher teacher2=loginService.findTeachByUsername(teacher);
			if(teacher2!=null) {
				session.setAttribute("teacher", teacher2);
				ModelAndView mav = new ModelAndView("/teacher/indext");
				return mav;
			}else {
				ModelAndView mav = new ModelAndView("error");
				return mav;
			}
		}else if("manage".equals(people)){
			Admin admin =new Admin();
			admin.setUsername(username);
			List<Student> list=(List<Student>) session.getAttribute("list");
			JSONObject jsonobj=new JSONObject();
			jsonobj.put("code", 0);
			jsonobj.put("msg", "成功");
			jsonobj.put("count",list.size());
			JSONArray jsonobj2=new JSONArray();
			JSONObject jsonobj3=new JSONObject();
		    for(Student student:list) {
		    	jsonobj3.put("id",student.getId());
		    	jsonobj3.put("username",student.getUsername());
		    	jsonobj3.put("password",student.getPassword());
		    	jsonobj3.put("stuclass",student.getStuclass());
		    	jsonobj3.put("stuname",student.getStuname());
		    	jsonobj3.put("stuno",student.getStuno());
		    	jsonobj2.add(jsonobj3);
		    }
		    jsonobj.put("data", jsonobj2);		
			return jsonobj.toString();
		}
	//老师
		@RequestMapping("/addtea")
		public ModelAndView addteacher(Teacher teacher,Model model) {
			adminService.addteacher(teacher);
			ModelAndView mav = new ModelAndView("admin/teamanage");
			return mav;
		}
		@RequestMapping(value = "/teamanage",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
		@ResponseBody
		public String teamanage(Model model) {
			List<Teacher> list=adminService.teamanage();
			JSONObject jsonobj=new JSONObject();
			jsonobj.put("code", 0);
			jsonobj.put("msg", "成功");
			jsonobj.put("count",list.size());
			JSONArray jsonobj2=new JSONArray();
			JSONObject jsonobj3=new JSONObject();
		    for(Teacher teacher:list) {
		    	jsonobj3.put("id",teacher.getId());
		    	jsonobj3.put("username",teacher.getUsername());
		    	jsonobj3.put("password",teacher.getPassword());
		    	jsonobj3.put("teaname",teacher.getTeaname());
		    	jsonobj2.add(jsonobj3);
		    }
		    jsonobj.put("data", jsonobj2);		
	}
	//学生
	@RequestMapping("/hrefaddstu")
	public ModelAndView addstu(Model model) {
		ModelAndView mav = new ModelAndView("admin/addstu");
		return mav;
	}
	@RequestMapping("/hrefmohuname")
	public ModelAndView hrefmohuname(String stuname,Model model,HttpSession session) {
		List<Student> list=adminService.selectbyname(stuname);
		session.setAttribute("list", list);
		ModelAndView mav = new ModelAndView("admin/mohuname");
		return mav;
	}
	@RequestMapping("/hrefxiustu")
	public String xiustu(String id,Model model) {
		Student student=adminService.selectone(id);
		model.addAttribute("student",student);
		return "admin/updatestu";
	}
	@RequestMapping("/hrefstumanage")
	public ModelAndView hrefstumanage(Model model) {
		ModelAndView mav = new ModelAndView("admin/stumanage");
		return mav;
	}
//老师
	@RequestMapping("/hrefaddtea")
	public ModelAndView hrefaddtea(Model model) {
		ModelAndView mav = new ModelAndView("admin/addtea");
		return mav;
	}
	@RequestMapping("/hrefteamanage")
	public ModelAndView hrefteamanage(Model model) {
		ModelAndView mav = new ModelAndView("admin/teamanage");
		return mav;
	}
	@RequestMapping("/hrefmohunametea")
	public ModelAndView hrefmohunametea(String teaname,Model model,HttpSession session) {
		List<Teacher> list=adminService.selectbynametea(teaname);
		session.setAttribute("tealist",list);
		ModelAndView mav = new ModelAndView("admin/mohuname2");
		return mav;
	}
		    	jsonobj3.put("username",student.getUsername());
		    	jsonobj3.put("password",student.getPassword());
		    	jsonobj3.put("stuclass",student.getStuclass());
		    	jsonobj3.put("stuname",student.getStuname());
		    	jsonobj3.put("stuno",student.getStuno());
		    	jsonobj2.add(jsonobj3);
		    }
		    jsonobj.put("data", jsonobj2);		
			return jsonobj.toString();
		}
	//老师
		@RequestMapping("/addtea")
		public ModelAndView addteacher(Teacher teacher,Model model) {
			adminService.addteacher(teacher);
			ModelAndView mav = new ModelAndView("admin/teamanage");
			return mav;
		}
		@RequestMapping(value = "/teamanage",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
		@ResponseBody
		public String teamanage(Model model) {
			List<Teacher> list=adminService.teamanage();
			JSONObject jsonobj=new JSONObject();
			jsonobj.put("code", 0);
			jsonobj.put("msg", "成功");
			jsonobj.put("count",list.size());
			JSONArray jsonobj2=new JSONArray();
			JSONObject jsonobj3=new JSONObject();
		    for(Teacher teacher:list) {
		    	jsonobj3.put("id",teacher.getId());
		    	jsonobj3.put("username",teacher.getUsername());
		    	jsonobj3.put("password",teacher.getPassword());
		    	jsonobj3.put("teaname",teacher.getTeaname());
		    	jsonobj2.add(jsonobj3);
		    }
		    jsonobj.put("data", jsonobj2);		
			return jsonobj.toString();
		}
		@RequestMapping("/deltea")
		public ModelAndView deltea(String id,Model model) {
			adminService.delteacher(id);
			ModelAndView mav = new ModelAndView("admin/teamanage");
			return mav;
		}
		@RequestMapping("/updatetea")
		    	jsonobj2.add(jsonobj3);
		    }
		    jsonobj.put("data", jsonobj2);		
			return jsonobj.toString();
		}
}

@Controller
public class TeachController {
	@Autowired
	private AdminService adminService;
	@Autowired
	private GeneraService generaService;
	@RequestMapping("/hrefaddscore")
	public ModelAndView hrefaddscore(Model model) {
		ModelAndView mav = new ModelAndView("teacher/addscore");
		return mav;
	}
	@RequestMapping("/hrefupdatepw")
	public ModelAndView hrefupdatepw(Model model) {
		ModelAndView mav = new ModelAndView("teacher/updatepw");
		return mav;
	}
	@RequestMapping(value = "/stuscore",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
	@ResponseBody
	public String stuscoree(Page page,Model model) {
		List<Student> list=adminService.stumanage();
		page.caculatestart();
		List<Student> list2=adminService.liststudent(page);
		JSONObject jsonobj=new JSONObject();
		jsonobj.put("code", 0);
		jsonobj.put("msg", "成功");
		jsonobj.put("count",list.size());
	}
	@RequestMapping("/hrefmohuname")
	public ModelAndView hrefmohuname(String stuname,Model model,HttpSession session) {
		List<Student> list=adminService.selectbyname(stuname);
		session.setAttribute("list", list);
		ModelAndView mav = new ModelAndView("admin/mohuname");
		return mav;
	}
	@RequestMapping("/hrefxiustu")
	public String xiustu(String id,Model model) {
		Student student=adminService.selectone(id);
		model.addAttribute("student",student);
		return "admin/updatestu";
	}
	@RequestMapping("/hrefstumanage")
	public ModelAndView hrefstumanage(Model model) {
		ModelAndView mav = new ModelAndView("admin/stumanage");
		return mav;
	}
//老师
	@RequestMapping("/hrefaddtea")
	public ModelAndView hrefaddtea(Model model) {
		ModelAndView mav = new ModelAndView("admin/addtea");
		return mav;
	}
	@RequestMapping("/hrefteamanage")
	public ModelAndView hrefteamanage(Model model) {
		ModelAndView mav = new ModelAndView("admin/teamanage");
		return mav;
	}
	@RequestMapping("/hrefmohunametea")
	public ModelAndView hrefmohunametea(String teaname,Model model,HttpSession session) {
		List<Teacher> list=adminService.selectbynametea(teaname);
		session.setAttribute("tealist",list);
		ModelAndView mav = new ModelAndView("admin/mohuname2");
		return mav;
	}
	@RequestMapping("/hrefxiutea")
	public String hrefxiutea(String id,Model model) {
		Teacher teacher=adminService.selectonetea(id);
		model.addAttribute("teacher",teacher);
	public ModelAndView hrefteamanage(Model model) {
		ModelAndView mav = new ModelAndView("admin/teamanage");
		return mav;
	}
	@RequestMapping("/hrefmohunametea")
	public ModelAndView hrefmohunametea(String teaname,Model model,HttpSession session) {
		List<Teacher> list=adminService.selectbynametea(teaname);
		session.setAttribute("tealist",list);
		ModelAndView mav = new ModelAndView("admin/mohuname2");
		return mav;
	}
	@RequestMapping("/hrefxiutea")
	public String hrefxiutea(String id,Model model) {
		Teacher teacher=adminService.selectonetea(id);
		model.addAttribute("teacher",teacher);
		return "admin/updatetea";
	}
}

@Controller
public class LoginController {
	@Autowired
	private LoginService loginService;	
	@RequestMapping("/login")
	public ModelAndView findCustomerById(String username,String password,String people,Model model,HttpSession session) {
		if("student".equals(people)) {
			Student student=new Student();
			student.setUsername(username);
			student.setPassword(password);
			Student student2=loginService.findStuTeachByUsername(student);
			if(student2!=null) {
				session.setAttribute("student", student2);
				ModelAndView mav = new ModelAndView("/student/indexs");
				return mav;
			}else {
				ModelAndView mav = new ModelAndView("error");
				return mav;
			}
		}else if("teacher".equals(people)){
			Teacher teacher=new Teacher();

@Controller
public class LoginController {
	@Autowired
	private LoginService loginService;	
	@RequestMapping("/login")
	public ModelAndView findCustomerById(String username,String password,String people,Model model,HttpSession session) {
		if("student".equals(people)) {
			Student student=new Student();
			student.setUsername(username);
			student.setPassword(password);
			Student student2=loginService.findStuTeachByUsername(student);
			if(student2!=null) {
				session.setAttribute("student", student2);
				ModelAndView mav = new ModelAndView("/student/indexs");
				return mav;
			}else {
				ModelAndView mav = new ModelAndView("error");
				return mav;
			}
		}else if("teacher".equals(people)){
			Teacher teacher=new Teacher();
			teacher.setUsername(username);
			teacher.setPassword(password);
			Teacher teacher2=loginService.findTeachByUsername(teacher);
			if(teacher2!=null) {
				session.setAttribute("teacher", teacher2);
				ModelAndView mav = new ModelAndView("/teacher/indext");
				return mav;
			}else {
				ModelAndView mav = new ModelAndView("error");
				return mav;
			}
		}else if("manage".equals(people)){
			Admin admin =new Admin();
			admin.setUsername(username);
			admin.setPassword(password);
			if(loginService.findAdminById(admin)!=null) {
				ModelAndView mav = new ModelAndView("/admin/index");
				return mav;
			}else {
				ModelAndView mav = new ModelAndView("error");
		return mav;
	}
	@RequestMapping(value = "/stuscore",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
	@ResponseBody
	public String stuscoree(Page page,Model model) {
		List<Student> list=adminService.stumanage();
		page.caculatestart();
		List<Student> list2=adminService.liststudent(page);
		JSONObject jsonobj=new JSONObject();
		jsonobj.put("code", 0);
		jsonobj.put("msg", "成功");
		jsonobj.put("count",list.size());
		JSONArray jsonobj2=new JSONArray();
		JSONObject jsonobj3=new JSONObject();
	    for(Student student:list2) {
	    	jsonobj3.put("id",student.getId());
	    	jsonobj3.put("stuno", student.getStuno());
	    	jsonobj3.put("stuname",student.getStuname());
	    	jsonobj3.put("stuclass",student.getStuclass());
	    	jsonobj3.put("score",student.getScore());    	
	    	jsonobj2.add(jsonobj3);
	    }
	    jsonobj.put("data", jsonobj2);		
		return jsonobj.toString();
	}
	@RequestMapping("/updatepw")
	public ModelAndView updatepw(Teacher teacher,Model model) {
		this.generaService.updatepw(teacher);
		ModelAndView mav = new ModelAndView("success");
		return mav;
	}
	@RequestMapping("/updatescore")
	public ModelAndView updatescore(String id,String score,Model model) {
		Student student=new Student();
		student.setId(Integer.parseInt(id));
		student.setScore(score);
		this.generaService.updatescore(student);
		ModelAndView mav = new ModelAndView("teacher/addscore");
		return mav;
	}
}
	public String hrefxiutea(String id,Model model) {
		Teacher teacher=adminService.selectonetea(id);
		model.addAttribute("teacher",teacher);
		return "admin/updatetea";
	}
}

@Controller
public class LoginController {
	@Autowired
	private LoginService loginService;	
	@RequestMapping("/login")
	public ModelAndView findCustomerById(String username,String password,String people,Model model,HttpSession session) {
		if("student".equals(people)) {
			Student student=new Student();
			student.setUsername(username);
			student.setPassword(password);
			Student student2=loginService.findStuTeachByUsername(student);
			if(student2!=null) {
				session.setAttribute("student", student2);
				ModelAndView mav = new ModelAndView("/student/indexs");
				return mav;
			}else {
				ModelAndView mav = new ModelAndView("error");
				return mav;
			}
		}else if("teacher".equals(people)){
			Teacher teacher=new Teacher();
			teacher.setUsername(username);
			teacher.setPassword(password);
			Teacher teacher2=loginService.findTeachByUsername(teacher);
			if(teacher2!=null) {
				session.setAttribute("teacher", teacher2);
				ModelAndView mav = new ModelAndView("/teacher/indext");
				return mav;

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐