@Autowired private GeneraService generaService; //学生 @RequestMapping("/hrefstuinfo") public ModelAndView hrefstuinfo(Model model) { ModelAndView mav = new ModelAndView("student/stuinfo"); return mav; } @RequestMapping("/hrefupdatepws") public ModelAndView hrefupdatepws(Model model) { ModelAndView mav = new ModelAndView("student/updatepws"); return mav; } @RequestMapping("/updatepws") public ModelAndView updatepws(Student student,Model model) { this.generaService.updatepws(student); ModelAndView mav = new ModelAndView("success"); return mav; }
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 list=adminService.stumanage(); page.caculatestart(); List 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; }
@RequestMapping("/updatecourse")
public ModelAndView updatecourse(Teacher teacher,Model model) {
this.generaService.updatepw(teacher);
ModelAndView mav = new ModelAndView("success");
return mav;
}
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());
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;
}
@RequestMapping("/updatecourse")
public ModelAndView updatecourse(Teacher teacher,Model model) {
this.generaService.updatepw(teacher);
ModelAndView mav = new ModelAndView("success");
return mav;
}
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
ID | 学号 | 名字 | 班级 | 分数 |
---|
这个是在控制器里面查询数据库的数据,返回json格式数据,应该是一个接口。