基于javaweb+mysql的springboot田径运动会管理系统(java+springboot+thymeleaf+html+maven+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot田径运动会管理系统(java+springboot+thymeleaf+html+maven+mysql)
项目介绍
本项目分为管理员、学生两种角色, 管理员主要功能包括: 功能:登录、查看个人资料、修改密码、选手管理、赛事管理、报名管理、成绩管理、开幕式管理、闭幕式管理 学生主要功能包括: 首页, 项目管理:报名项目、查看已报名项目; 成绩查询:单个项目查询、总成绩查询、个人总积分查询; 查看开幕式; 查看闭幕式; 个人资料:查看个人资料、修改密码;
环境需要
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 8.0版本;
6.是否Maven项目:是;
技术栈
-
后端:SpringBoot
-
前端:Thymeleaf+HTML+CSS+jQuery
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录 管理员账号/密码:10001/123456 学生账号/密码:1001/123456
// for(Cookie cookie:cookies){
// if("id".equals(cookie.getName())){
// value1 = cookie.getValue();
// }
// if("password".equals(cookie.getName())){
// value2 = cookie.getValue();
// }
// }
// model.addAttribute("id",value1);
// model.addAttribute("password",value2);
model.addAttribute("id",id);
model.addAttribute("password",password);
model.addAttribute("userType",userType);
return "login.html";
}
}
else {
Student student = studentService.queryStuById(id);
if (captchaId.toLowerCase().equals(parameter.toLowerCase())) {
if (student != null && password.equals(student.getPassword())) {
//用户存在,登录成功
session.setAttribute("student", student);
Cookie cookie1=new Cookie("id",student.getId()+"");
cookie1.setMaxAge(60*60*24);
response.addCookie(cookie1);
return "redirect:student/index-stu.html";
} else {
model.addAttribute("msg", "用户名或者密码错误!");
model.addAttribute("id",id);
model.addAttribute("userType",userType);
return "login.html";
}
} else {
//验证码错误
model.addAttribute("msg", "验证码错误!");
model.addAttribute("id",id);
model.addAttribute("password",password);
model.addAttribute("userType",userType);
return "login.html";
}
}
}
@RequestMapping("/admin/logout")
return "admin/ceremonyOpen-upd";
}
//修改开幕式
@RequestMapping("/admin/updCeremonyOpen")
@ResponseBody
public Msg updCeremonyOpen(CeremonyOpen ceremonyOpen){
//System.out.println(ceremonyOpen);
ceremonyService.updCeremonyOpen(ceremonyOpen);
return Msg.success().add("msg","修改成功");
}
//删除开幕式
@RequestMapping(value = "/admin/delCeremony/{ceremonyId}",method = RequestMethod.DELETE)
@ResponseBody
public Msg delCeremony(@PathVariable("ceremonyId")String ceremonyId){
ceremonyService.delCeremonyOpen(ceremonyId);
return Msg.success().add("msg","删除成功!");
}
//打开闭幕式页面
@RequestMapping("/admin/toCeremonyClose")
public String toCeremonyClose(Model model){
CeremonyClose ceremonyClose = ceremonyService.getCeremonyClose();
//System.out.println(ceremonyOpen);
model.addAttribute("ceremonyClose",ceremonyClose);
return "admin/ceremony-close";
}
//去添加闭幕式页面
@RequestMapping("/admin/toAddCeremonyClose")
public String toAddCeremonyClose(Model model){
return "admin/ceremonyClose-add";
}
//添加闭幕式
@RequestMapping("/admin/addCeremonyClose")
@ResponseBody
public Msg addCeremonyClose(CeremonyClose ceremonyClose){
//System.out.println(ceremonyOpen);
ceremonyService.addCeremonyClose(ceremonyClose);
return Msg.success().add("msg","添加成功");
}
//去修改闭幕式页面
@RequestMapping("/admin/toUpdCeremonyClose/{ceremonyId}")
public String toUpdCeremonyClose(@PathVariable("ceremonyId")String ceremonyId, Model model){
//System.out.println(ceremonyId);
CeremonyClose ceremonyCloseById = ceremonyService.getCeremonyCloseById(ceremonyId);
model.addAttribute("ceremonyCloseById",ceremonyCloseById);
@ResponseBody
public Msg updScore(SportsScore sportsScore,Model model){
//System.out.println(sportsScore);
gradeService.updScore(sportsScore);
return Msg.success().add("msg","修改成功");
}
//查询总项目情况
@RequestMapping("/admin/toGetScoreAll/{pn}")
public String toGetScoreAll(@PathVariable(value = "pn") Integer pn,Model model){
List schoolName = studentService.querySchool();
model.addAttribute("schoolName",schoolName);
PageHelper.startPage(pn,5);
List scoreAll = gradeService.getScoreAll();
PageInfo page=new PageInfo(scoreAll,5);
model.addAttribute("pageInfo",page);
model.addAttribute("sign","toGetScoreAll");
model.addAttribute("signTable","toGetScoreAll");
//System.out.println(page);
return "admin/score-all";
}
String gender;
String school;
//查询总项目情况--带条件
@RequestMapping("/admin/getScoreAllWithCondition/{pn}")
public String getScoreAllWithCondition(@RequestParam(value = "school",required = false)String school,
@RequestParam(value = "gender",required = false)String gender,
@PathVariable(value = "pn") Integer pn,
Model model){
if(school!=null||gender!=null) {
this.school = school;
this.gender = gender;
}
// System.out.println(this.id+"-->"+this.gender+"-->"+this.school);
List schoolName = studentService.querySchool();
model.addAttribute("schoolName",schoolName);
model.addAttribute("school",this.school);
model.addAttribute("gender",this.gender);
PageHelper.startPage(pn,5);
List scoreAllWithCondition = gradeService.getScoreAllWithCondition(this.school, this.gender);
PageInfo page=new PageInfo(scoreAllWithCondition,5);
@RequestMapping("/admin/getSports/{pn}")
public String getStuWithJson(@PathVariable(value = "pn") Integer pn,Model model){
PageHelper.startPage(pn,5);
//startPage后面紧跟的这个查询就是一个分页查询
List<Sports> sports=sportsService.querySports();
List sportsName = sportsService.querySportsName();
model.addAttribute("sports",sports);
model.addAttribute("sportsName",sportsName);
PageInfo page=new PageInfo(sports,5);
//System.out.println(page);
model.addAttribute("pageInfo",page);
model.addAttribute("sign","getSports");
return "admin/sports-list";
}
String sportsName;
String sportsType;
//分页显示运动项目----带条件
@RequestMapping("/admin/querySportsWithCondition/{pn}")
public String querySportsWithCondition(@RequestParam(value = "sportsName",required = false)String sportsName,
@RequestParam(value = "sportsType",required = false)String sportsType,
@PathVariable(value = "pn") Integer pn,
Model model){
if(sportsName!=null||sportsType!=null) {
this.sportsName = sportsName;
this.sportsType = sportsType;
}
// System.out.println(this.id+"-->"+this.gender+"-->"+this.school);
List sportsName1 = sportsService.querySportsName();
model.addAttribute("sportsName",sportsName1);
model.addAttribute("sports",this.sportsName);
model.addAttribute("sportsType",this.sportsType);
PageHelper.startPage(pn,5);
List<Sports> sports=sportsService.querySportsWithCondition(this.sportsName,this.sportsType);
PageInfo page=new PageInfo(sports,5);
model.addAttribute("pageInfo",page);
model.addAttribute("sign","querySportsWithCondition");
return "admin/sports-list";
}
@RequestParam("studentPassword2")String studentPassword2){
// System.out.println(adminId+"--"+adminPassword+"--"+adminPassword2);
studentService.updStuWithPassword(studentPassword,id);
return Msg.success().add("msg","修改成功!请重新登录");
}
}
package com.xhu.controller;
@Controller
public class StudentController {
@Autowired
private StudentService studentService;
// @RequestMapping("/admin/getStu")
public String getStu(Model model){
Collection<Student> list = studentService.queryStu();
model.addAttribute("students",list);
return "admin/student-list";
}
//分页显示学生
@RequestMapping("/admin/getStu/{pn}")
public String getStuWithJson(@PathVariable(value = "pn") Integer pn,Model model){
//这不是分页查询
}
package com.xhu.controller;
@Controller
public class LoginController {
@Autowired
DefaultKaptcha defaultKaptcha;
@Autowired
StudentService studentService;
@Autowired
AdminService adminService;
// @RequestMapping("/login.html")
// public String login(){
// return "login";
// }
//获取验证码
@RequestMapping("/getCode")
@ResponseBody
public Msg addCeremonyOpen(CeremonyOpen ceremonyOpen){
//System.out.println(ceremonyOpen);
ceremonyService.addCeremonyOpen(ceremonyOpen);
return Msg.success().add("msg","添加成功");
}
//去修改开幕式页面
@RequestMapping("/admin/toUpdCeremonyOpen/{ceremonyId}")
public String toUpdCeremonyOpen(@PathVariable("ceremonyId")String ceremonyId, Model model){
//System.out.println(ceremonyId);
CeremonyOpen ceremonyOpenById = ceremonyService.getCeremonyOpenById(ceremonyId);
model.addAttribute("ceremonyOpenById",ceremonyOpenById);
return "admin/ceremonyOpen-upd";
}
//修改开幕式
@RequestMapping("/admin/updCeremonyOpen")
@ResponseBody
public Msg updCeremonyOpen(CeremonyOpen ceremonyOpen){
//System.out.println(ceremonyOpen);
ceremonyService.updCeremonyOpen(ceremonyOpen);
return Msg.success().add("msg","修改成功");
}
//删除开幕式
@RequestMapping(value = "/admin/delCeremony/{ceremonyId}",method = RequestMethod.DELETE)
@ResponseBody
public Msg delCeremony(@PathVariable("ceremonyId")String ceremonyId){
ceremonyService.delCeremonyOpen(ceremonyId);
return Msg.success().add("msg","删除成功!");
}
//打开闭幕式页面
@RequestMapping("/admin/toCeremonyClose")
public String toCeremonyClose(Model model){
CeremonyClose ceremonyClose = ceremonyService.getCeremonyClose();
//System.out.println(ceremonyOpen);
model.addAttribute("ceremonyClose",ceremonyClose);
return "admin/ceremony-close";
}
//去添加闭幕式页面
@RequestMapping("/admin/toAddCeremonyClose")
public String toAddCeremonyClose(Model model){
return "admin/ceremonyClose-add";
}
//查看管理员资料
@RequestMapping("/admin/toGetAdmin/{adminId}")
public String toGetAdmin(@PathVariable("adminId")Integer adminId,Model model){
//System.out.println(adminId);
Admin admin = adminService.queryAdminById(adminId);
model.addAttribute("admin",admin);
return "admin/admin-data";
}
//修改管理员资料
@RequestMapping("/admin/updAdmin")
@ResponseBody
public Msg toGetAdmin( @RequestParam("adminId")Integer adminId,
@RequestParam("adminName")String adminName,
@RequestParam("adminGender")String adminGender,
@RequestParam("adminAge")Integer adminAge,
@RequestParam("adminPhone")String adminPhone,
Model model){
//System.out.println(adminId);
//System.out.println(adminName+"--"+adminGender+"--"+adminAge+"--"+adminPhone);
adminService.updAdmin(adminName,adminGender,adminAge,adminPhone,adminId);
return Msg.success().add("msg","修改成功!");
}
//去修改管理员密码界面
@RequestMapping("/admin/toUpdAdminPass/{adminId}")
public String toUpdAdminPass(@PathVariable("adminId")Integer adminId,Model model){
//System.out.println(adminId);
model.addAttribute("adminId",adminId);
return "admin/admin-pass-upd";
}
//修改管理员密码
@RequestMapping("/admin/updAdminPass")
@ResponseBody
public Msg updAdminPass( @RequestParam("adminId")Integer adminId,
@RequestParam("adminPassword")String adminPassword,
@RequestParam("adminPassword2")String adminPassword2){
// System.out.println(adminId+"--"+adminPassword+"--"+adminPassword2);
adminService.updAdminPass(adminPassword,adminId);
return Msg.success().add("msg","修改成功!请重新登录");
}
}
package com.xhu.controller;
}
//修改学生信息
@RequestMapping("/admin/updStu")
@ResponseBody
public Msg updStu(Student student){
// System.out.println(student);
studentService.updStu(student);
return Msg.success();
}
@RequestMapping(value = "/admin/delStuById/{stuId}",method = RequestMethod.DELETE)
public String delStuById(@PathVariable("stuId") String stuId){
int id=Integer.parseInt(stuId);
studentService.delStuById(id);
return "redirect:admin/getStu/1";
}
}
package com.xhu.config;
public class LoginHandlerInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//登录成功后,应该有用户的session
Object student = request.getSession().getAttribute("student");
Object admin = request.getSession().getAttribute("admin");
if(student==null&&admin==null){
request.setAttribute("msg","没有权限,请先登录!");
request.getRequestDispatcher("/login.html").forward(request,response);
return false;
}
// Cookie[] cookies=request.getCookies();
// for(Cookie cookie:cookies){
// if("id".equals(cookie.getName())){
// value1 = cookie.getValue();
// }
// if("password".equals(cookie.getName())){
// value2 = cookie.getValue();
// }
// }
// model.addAttribute("id",value1);
// model.addAttribute("password",value2);
model.addAttribute("id",id);
model.addAttribute("password",password);
model.addAttribute("userType",userType);
return "login.html";
}
}
else {
Student student = studentService.queryStuById(id);
if (captchaId.toLowerCase().equals(parameter.toLowerCase())) {
if (student != null && password.equals(student.getPassword())) {
//用户存在,登录成功
session.setAttribute("student", student);
Cookie cookie1=new Cookie("id",student.getId()+"");
cookie1.setMaxAge(60*60*24);
response.addCookie(cookie1);
return "redirect:student/index-stu.html";
} else {
model.addAttribute("msg", "用户名或者密码错误!");
model.addAttribute("id",id);
model.addAttribute("userType",userType);
return "login.html";
}
} else {
//验证码错误
model.addAttribute("msg", "验证码错误!");
model.addAttribute("id",id);
model.addAttribute("password",password);
model.addAttribute("userType",userType);
return "login.html";
}
}
}
@RequestMapping("/admin/logout")
public String logout(HttpSession session){
session.invalidate();
PageHelper.startPage(pn,5);
List scoreAll = gradeService.getScoreAll();
PageInfo page=new PageInfo(scoreAll,5);
model.addAttribute("pageInfo",page);
model.addAttribute("sign","toGetScoreAll");
model.addAttribute("signTable","toGetScoreAll");
//System.out.println(page);
return "admin/score-all";
}
String gender;
String school;
//查询总项目情况--带条件
@RequestMapping("/admin/getScoreAllWithCondition/{pn}")
public String getScoreAllWithCondition(@RequestParam(value = "school",required = false)String school,
@RequestParam(value = "gender",required = false)String gender,
@PathVariable(value = "pn") Integer pn,
Model model){
if(school!=null||gender!=null) {
this.school = school;
this.gender = gender;
}
// System.out.println(this.id+"-->"+this.gender+"-->"+this.school);
List schoolName = studentService.querySchool();
model.addAttribute("schoolName",schoolName);
model.addAttribute("school",this.school);
model.addAttribute("gender",this.gender);
PageHelper.startPage(pn,5);
List scoreAllWithCondition = gradeService.getScoreAllWithCondition(this.school, this.gender);
PageInfo page=new PageInfo(scoreAllWithCondition,5);
model.addAttribute("pageInfo",page);
model.addAttribute("sign","scoreAllWithCondition");
model.addAttribute("signTable","toGetScoreAll");
return "admin/score-all";
}
//查询学校总分情况
String sportsType;
@RequestMapping("/admin/scoreAll/{pn}")
public String scoreAll(@RequestParam(value = "sportsType",required = false)String sportsType,
@PathVariable(value = "pn") Integer pn,
Model model){
//System.out.println(this.sportsType);
if(sportsType!=null)
this.sportsType=sportsType;
//分页显示个人成绩
@RequestMapping("/student/toPersonalScore/{pn}")
public String getScoreBySchool(@PathVariable(value = "pn") Integer pn, Model model, HttpServletRequest request){
//startPage后面紧跟的这个查询就是一个分页查询
List school1 = studentService.querySchool();
model.addAttribute("schoolName",school1);
PageHelper.startPage(pn,5);
List scoreBySchool = gradeService.getScoreBySchool();
//System.out.println(scoreBySchool);
PageInfo page=new PageInfo(scoreBySchool,5);
//System.out.println(page);
model.addAttribute("pageInfo",page);
model.addAttribute("sign","getSports");
return "admin/scoreAllBySchool";
}
String school;
String gender;
//分页显示个人成绩----带条件
@RequestMapping("/student/getScoreBySchoolWithCondition/{pn}")
public String getScoreBySchoolWithCondition(@RequestParam(value = "school",required = false)String school,
@RequestParam(value = "gender",required = false)String gender,
@PathVariable(value = "pn") Integer pn,
Model model){
if(school!=null||gender!=null) {
this.school = school;
this.gender = gender;
}
// System.out.println(this.id+"-->"+this.gender+"-->"+this.school);
List school1 = studentService.querySchool();
model.addAttribute("schoolName",school1);
model.addAttribute("school",this.school);
model.addAttribute("gender",this.gender);
PageHelper.startPage(pn,5);
List score = gradeService.getScoreBySchoolWithCondition(this.school, this.gender);
PageInfo page=new PageInfo(score,5);
model.addAttribute("pageInfo",page);
model.addAttribute("sign","querySportsWithCondition");
return "admin/scoreAllBySchool";
}
}
adminService.updAdmin(adminName,adminGender,adminAge,adminPhone,adminId);
return Msg.success().add("msg","修改成功!");
}
//去修改管理员密码界面
@RequestMapping("/admin/toUpdAdminPass/{adminId}")
public String toUpdAdminPass(@PathVariable("adminId")Integer adminId,Model model){
//System.out.println(adminId);
model.addAttribute("adminId",adminId);
return "admin/admin-pass-upd";
}
//修改管理员密码
@RequestMapping("/admin/updAdminPass")
@ResponseBody
public Msg updAdminPass( @RequestParam("adminId")Integer adminId,
@RequestParam("adminPassword")String adminPassword,
@RequestParam("adminPassword2")String adminPassword2){
// System.out.println(adminId+"--"+adminPassword+"--"+adminPassword2);
adminService.updAdminPass(adminPassword,adminId);
return Msg.success().add("msg","修改成功!请重新登录");
}
}
package com.xhu.controller;
@Controller
public class StuSportsController {
@Autowired
private SportsService sportsService;
@Autowired
private RefereeService refereeService;
@Autowired
private StudentService studentService;
@Autowired
GradeService gradeService;
//System.out.println(ceremonyId);
CeremonyClose ceremonyCloseById = ceremonyService.getCeremonyCloseById(ceremonyId);
model.addAttribute("ceremonyCloseById",ceremonyCloseById);
return "admin/ceremonyClose-upd";
}
//修改闭幕式
@RequestMapping("/admin/updCeremonyClose")
@ResponseBody
public Msg updCeremonyOpen(CeremonyClose ceremonyClose){
//System.out.println(ceremonyOpen);
ceremonyService.updCeremonyClose(ceremonyClose);
return Msg.success().add("msg","修改成功");
}
//删除闭幕式
@RequestMapping(value = "/admin/delCeremonyClose/{ceremonyId}",method = RequestMethod.DELETE)
@ResponseBody
public Msg delCeremonyClose(@PathVariable("ceremonyId")String ceremonyId){
ceremonyService.delCeremonyClose(ceremonyId);
return Msg.success().add("msg","删除成功!");
}
//查看管理员资料
@RequestMapping("/admin/toGetAdmin/{adminId}")
public String toGetAdmin(@PathVariable("adminId")Integer adminId,Model model){
//System.out.println(adminId);
Admin admin = adminService.queryAdminById(adminId);
model.addAttribute("admin",admin);
return "admin/admin-data";
}
//修改管理员资料
@RequestMapping("/admin/updAdmin")
@ResponseBody
public Msg toGetAdmin( @RequestParam("adminId")Integer adminId,
@RequestParam("adminName")String adminName,
@RequestParam("adminGender")String adminGender,
@RequestParam("adminAge")Integer adminAge,
@RequestParam("adminPhone")String adminPhone,
Model model){
//System.out.println(adminId);
//System.out.println(adminName+"--"+adminGender+"--"+adminAge+"--"+adminPhone);
adminService.updAdmin(adminName,adminGender,adminAge,adminPhone,adminId);
return Msg.success().add("msg","修改成功!");
}
//将sportsId返回
model.addAttribute("sportsId",sportsId);
//System.out.println(sportsId);
List scoreList = gradeService.selectWithStuAndSports(sportsId);
model.addAttribute("scoreDefault",scoreList);
return "student/scorelist-byOne";
}
//打开开幕式页面
@RequestMapping("/student/toCeremonyOpen")
public String toCeremonyOpen(Model model){
CeremonyOpen ceremonyOpen = ceremonyService.getCeremonyOpen();
//System.out.println(ceremonyOpen);
model.addAttribute("ceremonyOpen",ceremonyOpen);
return "student/ceremony-open";
}
//打开闭幕式页面
@RequestMapping("/student/toCeremonyClose")
public String toCeremonyClose(Model model){
CeremonyClose ceremonyClose = ceremonyService.getCeremonyClose();
//System.out.println(ceremonyOpen);
model.addAttribute("ceremonyClose",ceremonyClose);
return "student/ceremony-close";
}
//分页显示个人成绩
@RequestMapping("/student/toPersonalScore/{pn}")
public String getScoreBySchool(@PathVariable(value = "pn") Integer pn, Model model, HttpServletRequest request){
//startPage后面紧跟的这个查询就是一个分页查询
List school1 = studentService.querySchool();
model.addAttribute("schoolName",school1);
PageHelper.startPage(pn,5);
List scoreBySchool = gradeService.getScoreBySchool();
//System.out.println(scoreBySchool);
PageInfo page=new PageInfo(scoreBySchool,5);
//System.out.println(page);
model.addAttribute("pageInfo",page);
model.addAttribute("sign","getSports");
return "admin/scoreAllBySchool";
}
String school;
String gender;
//分页显示个人成绩----带条件
@RequestMapping("/student/getScoreBySchoolWithCondition/{pn}")
public String getScoreBySchoolWithCondition(@RequestParam(value = "school",required = false)String school,
@RequestParam(value = "gender",required = false)String gender,
@PathVariable(value = "pn") Integer pn,
Model model){
if(school!=null||gender!=null) {
this.school = school;
}
//修改管理员密码
@RequestMapping("/admin/updAdminPass")
@ResponseBody
public Msg updAdminPass( @RequestParam("adminId")Integer adminId,
@RequestParam("adminPassword")String adminPassword,
@RequestParam("adminPassword2")String adminPassword2){
// System.out.println(adminId+"--"+adminPassword+"--"+adminPassword2);
adminService.updAdminPass(adminPassword,adminId);
return Msg.success().add("msg","修改成功!请重新登录");
}
}
package com.xhu.controller;
@Controller
public class StuSportsController {
@Autowired
private SportsService sportsService;
@Autowired
private RefereeService refereeService;
@Autowired
private StudentService studentService;
@Autowired
GradeService gradeService;
@Autowired
CeremonyService ceremonyService;
//分页显示运动项目
@RequestMapping("/student/getSports/{pn}")
public String getStuWithJson(@PathVariable(value = "pn") Integer pn, Model model, HttpServletRequest request){
List schooltype = studentService.querySchool();
// System.out.println(school);
model.addAttribute("schooltype",schooltype);
//使用PageInfo包装查询后的结果,只需要将page交给页面就行了
//封装了详细的分页信息,包括我们查询出来的数据,传入连续显示的页数
PageInfo page=new PageInfo(students,5);
//System.out.println(page);
model.addAttribute("pageInfo",page);
model.addAttribute("sign","getStu");
return "admin/student-list";
}
Integer id;
String gender;
String school;
//分页显示学生----带条件
@RequestMapping("/admin/queryStuWithCondition/{pn}")
public String queryStuWithCondition(@RequestParam(value = "school",required = false)String school,
@RequestParam(value = "gender",required = false)String gender,
@RequestParam(value = "id",required = false)Integer id,
@PathVariable(value = "pn") Integer pn,
Model model){
//System.out.println(id+"-->"+gender+"-->"+school);
if(id!=null||gender!=null||school!=null) {
this.id = id;
this.gender = gender;
this.school = school;
}
// System.out.println(this.id+"-->"+this.gender+"-->"+this.school);
List schooltype = studentService.querySchool();
// System.out.println(school);
model.addAttribute("schooltype",schooltype);
model.addAttribute("id",this.id);
model.addAttribute("school",this.school);
model.addAttribute("gender",this.gender);
if(this.id==null){
PageHelper.startPage(pn,5);
List<Student> students=studentService.queryStuWithCondition(this.gender,this.school);
PageInfo page=new PageInfo(students,5);
model.addAttribute("pageInfo",page);
model.addAttribute("sign","getStuWithCondition");
return "admin/student-list";
}
else {
PageHelper.startPage(pn,5);
List<Student> students=studentService.queryStuWithCondition2(this.id,this.gender,this.school);
PageInfo page=new PageInfo(students,5);
model.addAttribute("pageInfo",page);
model.addAttribute("sign","getStuWithCondition");
return "admin/student-list";
}
}