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


    作者主页:夜未央5788

     简介: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

    1. package net.fuzui.StudentInfo.handler;
    2. import net.fuzui.StudentInfo.pojo.Student;
    3. import net.fuzui.StudentInfo.pojo.Teacher;
    4. import net.fuzui.StudentInfo.service.AdminService;
    5. import net.fuzui.StudentInfo.service.CoursePlanService;
    6. import net.fuzui.StudentInfo.service.CourseService;
    7. import net.fuzui.StudentInfo.service.SelectCourseService;
    8. import net.fuzui.StudentInfo.service.StudentService;
    9. import net.fuzui.StudentInfo.service.TeacherService;
    10. import net.fuzui.StudentInfo.service.impl.AdminServiceImpl;
    11. import org.springframework.beans.factory.annotation.Autowired;
    12. import org.springframework.http.HttpRequest;
    13. import org.springframework.stereotype.Controller;
    14. import org.springframework.ui.Model;
    15. import org.springframework.web.bind.annotation.PathVariable;
    16. import org.springframework.web.bind.annotation.RequestMapping;
    17. import org.springframework.web.bind.annotation.RequestMethod;
    18. import org.springframework.web.bind.annotation.RequestParam;
    19. import org.springframework.web.bind.annotation.SessionAttributes;
    20. import org.springframework.web.servlet.ModelAndView;
    21. import org.springframework.web.servlet.view.RedirectView;
    22. import com.github.pagehelper.PageHelper;
    23. import com.github.pagehelper.PageInfo;
    24. import java.util.ArrayList;
    25. import java.util.List;
    26. import javax.servlet.http.HttpServletRequest;
    27. import javax.servlet.http.HttpSession;
    28. @Controller
    29. @RequestMapping("/AdminHandler")
    30. //@SessionAttributes("studentList")
    31. //@SessionAttributes("teacherList")
    32. public class AdminHandler {
    33. @Autowired
    34. StudentService studentService;
    35. @Autowired
    36. TeacherService teacherService;
    37. @Autowired
    38. CoursePlanService coursePlanService;
    39. @Autowired
    40. CourseService courseService;
    41. @Autowired
    42. SelectCourseService selectCourseService;
    43. /**
    44. * JavaScript学的不好,目前只能通过这种方式把三级联动下拉列表的val改变为以下值传给数据库。
    45. *
    46. */
    47. String[] arr_belongcoll = {"计算机学院","建筑学院","外国语学院","人文学院"};
    48. String[][] arr_belongpro = {
    49. {"网络工程","软件工程","物联网","信息管理"},
    50. {"土木工程","测绘工程","工程造价", "城市规划"},
    51. {"英语", "日语", "俄语", "西班牙语"},
    52. {"汉语言", "历史", "新闻", "网络新媒体"}
    53. };
    54. String[][][] arr_belongcla = {
    55. {
    56. {"网络B151","网络B152","网络B161","网络B162","网络B171","网络B172"},
    57. {"软件B151","软件B152","软件B161","软件B162","软件B171","软件B172"},
    58. {"物联B151","物联B152","物联B161","物联B162","物联B171","物联B172"},
    59. {"信管B151","信管B152","信管B161","信管B162","信管B171","信管B172"}
    60. },
    61. {
    62. {"土木B151","土木B152","土木B161","土木B162","土木B171","土木B172"},
    63. {"测绘B151","测绘B152","测绘B161","测绘B162","测绘B171","测绘B172"},
    64. {"造价B151","造价B152","造价B161","造价B162","造价B171","造价B172"},
    65. {"规划B151","规划B152","规划B161","规划B162","规划B171","规划B172"}
    66. },
    67. {
    68. {"英语B151","英语B152","英语B161","英语B162","英语B171","英语B172"},
    69. {"日语B151","日语B152","日语B161","日语B162","日语B171","日语B172"},
    70. {"俄语B151","俄语B152","俄语B161","俄语B162","俄语B171","俄语B172"},
    71. {"牙语B151","牙语B152","牙语B161","牙语B162","牙语B171","牙语B172"}
    72. },
    73. {
    74. {"汉语B151","汉语B152","汉语B161","汉语B162","汉语B171","汉语B172"},
    75. {"历史B151","历史B152","历史B161","历史B162","历史B171","历史B172"},
    76. {"新闻B151","新闻B152","新闻B161","新闻B162","新闻B171","新闻B172"},
    77. {"网媒B151","网媒B152","网媒B161","网媒B162","网媒B171","网媒B172"}
    78. }
    79. };
    80. // 添加
    81. @RequestMapping("/addStudent")
    82. public String addStudent(Student student, Model model) {
    83. int col = Integer.parseInt(student.getCollege());
    84. int pro = Integer.parseInt(student.getProfession());
    85. int cla = Integer.parseInt(student.getClassr());
    86. //总感觉前端js写的有问题。
    87. student.setCollege(arr_belongcoll[pro]);
    88. student.setProfession(arr_belongpro[pro][col]);
    89. student.setClassr(arr_belongcla[pro][col][cla]);
    90. if (studentService.insertStudent(student) != 0) {
    91. model.addAttribute("student", student);
    92. return "success";
    93. // return "admin/addStudent";
    94. } else {
    95. return "fail";
    96. }
    97. }
    98. //查询全部学生方法
    99. public void queryStu(HttpServletRequest request) {
    100. List studentList = new ArrayList();
    101. studentList = studentService.selectStudentBySql(1,10);
    102. request.setAttribute("slist", studentList);
    103. }
    104. public void pageIn(Model model,List list) {
    105. PageInfo page = new PageInfo(list, 5);
    106. model.addAttribute("pageInfo", page);
    107. }
    108. // 查询
    109. @RequestMapping(value = "/query/{pn}", method = RequestMethod.GET)
    110. public String redirect(@RequestParam("serc") String serc, @RequestParam("condition") String condition,HttpServletRequest request,
    111. @PathVariable(value = "pn") String pn,Model model) {
    112. int no = Integer.parseInt(pn);
    113. // System.out.println("-----"+no+"----");
    114. List studentList = new ArrayList();
    115. PageHelper.startPage(no, 5);
    116. request.setAttribute("serc", serc);
    117. request.setAttribute("condition", condition);
    118. //查询全部
    119. if (serc.equals("all")) {
    120. System.out.println("------------------------------------------------------------------------------------------------");
    121. // studentList = studentService.selectStudentBySql(1,10);
    122. // //model.addAttribute("studentList", studentList);
    123. // request.setAttribute("slist", studentList);
    124. // System.out.println("00000"+request.getAttribute("slist"));
    125. // System.out.println(studentList);
    126. studentList = studentService.selectStudentBySql(1,10);
    127. pageIn(model, studentList);
    128. request.setAttribute("slist", studentList);
    129. return "admin/queryStudent";
    130. //根据学号查询
    131. } else if (serc.equals("sid")) {
    132. studentList = studentService.getByStudentSid(1,10,condition);
    133. pageIn(model, studentList);
    134. request.setAttribute("slist", studentList);
    135. System.out.println("sid");
    136. return "admin/queryStudent";
    137. //根据学院查询
    138. } else if (serc.equals("col")) {
    139. studentList = studentService.getByStudentCol(1,10,condition);
    140. pageIn(model, studentList);
    141. request.setAttribute("slist", studentList);
    142. System.out.println(studentList);
    143. System.out.println("col");
    144. return "admin/queryStudent";
    145. //根据专业查询
    146. } else if (serc.equals("pro")) {
    147. studentList = studentService.getByStudentPro(1,10,condition);
    148. pageIn(model, studentList);
    149. request.setAttribute("slist", studentList);
    150. System.out.println(studentList);
    151. System.out.println("pro");
    152. return "admin/queryStudent";
    153. //根据班级查询
    154. } else if (serc.equals("cla")) {
    155. studentList = studentService.getByStudentCla(1,10,condition);
    156. pageIn(model, studentList);
    157. //model.addAttribute("studentList", studentList);
    158. request.setAttribute("slist", studentList);
    159. // System.out.println(studentList);
    160. // System.out.println("cla");
    161. return "admin/queryStudent";
    162. } else {
    163. // studentList = studentService.selectStudentBySql(1,10);
    164. // model.addAttribute("studentList", studentList);
    165. // request.setAttribute("slist", studentList);
    166. // System.out.println("00000"+request.getAttribute("slist"));
    167. // System.out.println(studentList);
    168. studentList = studentService.selectStudentBySql(1,10);
    169. pageIn(model, studentList);
    170. request.setAttribute("slist", studentList);
    171. return "admin/queryStudent";
    172. }
    173. }
    174. // 删除学生
    175. @RequestMapping(value = "/delete/{sid}", method = RequestMethod.GET)
    176. public String deleteStudent(@PathVariable(value = "sid") String sid, Model model) {
    177. if (studentService.deleteStudent(sid) != 0) {
    178. System.out.println("success");
    179. return "success";
    180. } else {
    181. System.out.println("fail");
    182. return "fail";
    183. }
    184. }
    185. // 跳转页面
    186. @RequestMapping(value = "/finalPage", method = RequestMethod.GET)
    187. public String finalPage(HttpServletRequest request) {
    188. queryStu(request);
    189. return "admin/queryStudent";
    190. }
    191. // 修改定位
    192. @RequestMapping(value = "/moditystu/{sid}", method = RequestMethod.GET)
    193. public String editPre(@PathVariable("sid") String sid, HttpServletRequest request) {
    194. List studentList = new ArrayList();
    195. studentList = studentService.getByStudentSid(1,10,sid);
    196. request.setAttribute("studentList", studentList);
    197. System.out.println("-----进入修改");
    198. return "admin/modiStudent";
    199. }
    200. // 修改
    201. @RequestMapping(value = "/moditystud/{sid}", method = RequestMethod.GET)
    202. public String update(@PathVariable("sid") String sid, Student student, HttpServletRequest request) {
    203. int col = Integer.parseInt(student.getCollege());
    204. int pro = Integer.parseInt(student.getProfession());
    205. int cla = Integer.parseInt(student.getClassr());
    206. //总感觉前端js写的有问题。
    207. student.setCollege(arr_belongcoll[pro]);
    208. student.setProfession(arr_belongpro[pro][col]);
    209. student.setClassr(arr_belongcla[pro][col][cla]);
    210. if (studentService.modifyStudent(student) != 0) {
    211. System.out.println("----修改成功--------------------------------------------------------------------------------------------------------");
    212. return "success";
    213. } else {
    214. System.out.println("----修改失败----------------------------------------------------------------");
    215. return "fail";
    216. }
    217. }
    218. // 跳转页面
    219. @RequestMapping("/managestu/{pn}")
    220. public String manageStudent(HttpServletRequest request,
    221. @PathVariable(value = "pn") String pn,Model model) {
    222. int no = Integer.parseInt(pn);
    223. PageHelper.startPage(no, 5);
    224. List studentList = new ArrayList();
    225. studentList = studentService.selectStudentBySql(1,100);
    226. pageIn(model, studentList);
    227. request.setAttribute("slist", studentList);
    228. return "admin/queryStudent";
    229. }
    230. // 跳转页面
    231. @RequestMapping("/managetea/{pn}")
    232. public String manageTeacher(HttpServletRequest request,
    233. @PathVariable(value = "pn") String pn,Model model) {
    234. int no = Integer.parseInt(pn);
    235. PageHelper.startPage(no, 5);
    236. List teacherList = new ArrayList();
    237. teacherList = teacherService.selectTeacherBySql(1,10);
    238. pageIn(model, teacherList);
    239. request.setAttribute("teacherList", teacherList);
    240. return "admin/queryTeacher";
    241. }
    242. // 跳转页面
    243. @RequestMapping("/addstu")
    244. public String adStudent() {
    245. return "admin/addStudent";
    246. }
    247. // 跳转页面
    248. @RequestMapping("/addtea")
    249. public String adTeacher() {
    250. return "admin/addTeacher";
    251. }
    252. // 跳转页面
    253. @RequestMapping("/addcou")
    254. public String adCourse() {
    255. return "admin/addCourse";
    256. }
    257. // 添加
    258. @RequestMapping("/addTeacher")
    259. public String addTeacher(Teacher teacher, Model model, HttpSession httpSession) {
    260. if (teacherService.insertTeacher(teacher) != 0) {
    261. model.addAttribute("teacher", teacher);
    262. //---------------------------------待优化-----同样不能实时刷新--------------------------------------------
    263. return "success";
    264. //return new ModelAndView(new RedirectView("/StudentInfo/TeacherHandler/finalPage"));
    265. // return "techer/teacherFace";
    266. } else {
    267. return "fail";
    268. //return new ModelAndView(new RedirectView("fail"));
    269. }
    270. }
    271. /**
    272. * 教师相关
    273. */
    274. //查询全部教师方法
    275. public void queryTea(HttpServletRequest request) {
    276. List teacherList = new ArrayList();
    277. teacherList = teacherService.selectTeacherBySql(1,10);
    278. request.setAttribute("teacherList", teacherList);
    279. }
    280. // 查询
    281. @RequestMapping(value = "/queryTea/{pn}", method = RequestMethod.GET)
    282. public String redirectTea(@RequestParam("serc") String serc, @RequestParam("condition") String condition,HttpServletRequest request,
    283. @PathVariable(value = "pn") String pn,Model model) {
    284. int no = Integer.parseInt(pn);
    285. PageHelper.startPage(no, 5);
    286. List teacherList = new ArrayList();
    287. request.setAttribute("serc", serc);
    288. request.setAttribute("condition", condition);
    289. if (serc.equals("all")) {
    290. teacherList = teacherService.selectTeacherBySql(1,10);
    291. pageIn(model, teacherList);
    292. request.setAttribute("teacherList", teacherList);
    293. return "admin/queryTeacher";
    294. } else if (serc.equals("tid")) {
    295. teacherList = teacherService.getByTeacherTid(1,10,condition);
    296. pageIn(model, teacherList);
    297. request.setAttribute("teacherList", teacherList);
    298. System.out.println("tid");
    299. return "admin/queryTeacher";
    300. } else {
    301. teacherList = teacherService.selectTeacherBySql(1,10);
    302. pageIn(model, teacherList);
    303. request.setAttribute("teacherList", teacherList);
    304. return "admin/queryTeacher";
    305. }
    306. }
    307. //删除教师
    308. @RequestMapping(value = "/deleteTea/{tid}", method = RequestMethod.GET)
    309. public String deleteTeacher(@PathVariable(value = "tid") String tid, Model model) {
    310. if (teacherService.deleteTeacher(tid) != 0) {
    311. System.out.println("success");
    312. //------------------------代优化,现状:删除后需要手动刷新界面或者重新查询,不能实时刷新。---------------------------------------------------
    313. return "success";
    314. } else {
    315. System.out.println("fail");
    316. return "fail";
    317. }
    318. }
    319. @RequestMapping(value = "/finalPageTea", method = RequestMethod.GET)
    320. public String finalPageTea(HttpServletRequest request) {
    321. queryTea(request);
    322. return "admin/queryTeacher";
    323. }
    324. //修改定位,可优化
    325. @RequestMapping(value = "/modityTea/{tid}", method = RequestMethod.GET)
    326. public String editPreTea(@PathVariable("tid") String tid, HttpServletRequest request) {
    327. List teacherList = new ArrayList();
    328. teacherList = teacherService.getByTeacherTid(1,10,tid);
    329. //model.addAttribute("teacherList", teacherList);
    330. request.setAttribute("teacherList", teacherList);
    331. return "admin/modiTeacher";
    332. }
    333. // 修改
    334. @RequestMapping(value = "/modityTeac/{tid}", method = RequestMethod.GET)
    335. public String update(@PathVariable("tid") String tid, Teacher teacher, HttpServletRequest request) {
    336. if (teacherService.modifyTeacher(teacher) != 0) {
    337. return "success";
    338. } else {
    339. return "fail";
    340. }
    341. }
    342. }

    AjaxHandler

    1. package net.fuzui.StudentInfo.handler;
    2. import java.io.IOException;
    3. import java.io.PrintWriter;
    4. import java.io.UnsupportedEncodingException;
    5. import javax.servlet.http.HttpServletRequest;
    6. import javax.servlet.http.HttpServletResponse;
    7. import org.springframework.beans.factory.annotation.Autowired;
    8. import org.springframework.stereotype.Controller;
    9. import org.springframework.web.bind.annotation.RequestMapping;
    10. import org.springframework.web.bind.annotation.RequestMethod;
    11. import org.springframework.web.bind.annotation.RequestParam;
    12. import net.fuzui.StudentInfo.service.CoursePlanService;
    13. import net.fuzui.StudentInfo.service.CourseService;
    14. import net.fuzui.StudentInfo.service.StudentService;
    15. import net.fuzui.StudentInfo.service.TeacherService;
    16. @Controller
    17. @RequestMapping("/AjaxHandler")
    18. public class AjaxHandler {
    19. @Autowired
    20. CourseService courseService;
    21. @Autowired
    22. StudentService studentService;
    23. @Autowired
    24. TeacherService teacherService;
    25. @Autowired
    26. CoursePlanService coursePlanService;
    27. /**
    28. * ajax验证课程编号是否存在
    29. * @param cid
    30. * @param response
    31. * @param request
    32. * @throws IOException
    33. */
    34. @RequestMapping(value="/existCid",method = RequestMethod.POST)
    35. public void existCid(@RequestParam("cid") String cid,HttpServletResponse response,HttpServletRequest request) throws IOException{
    36. System.out.println("课程编号="+cid);
    37. response.setContentType("text/html;charset=UTF-8");
    38. response.setHeader("Cache-Control", "no-cache");
    39. System.out.println(cid+"----------");
    40. PrintWriter out=null;
    41. out=response.getWriter();
    42. if(courseService.getByCouCid(cid) != null && cid !=null && !"".equals(cid)){
    43. out.println("课程编号已存在");
    44. }else if(cid !=null && !"".equals(cid)){
    45. out.println("此课程编号可以使用");
    46. }else {
    47. out.println("课程编号不能为空");
    48. }
    49. out.flush();
    50. out.close();
    51. }
    52. @RequestMapping(value="/existSid",method = RequestMethod.POST)
    53. public void existSid(@RequestParam("sid") String sid,HttpServletResponse response,HttpServletRequest request) throws IOException{
    54. System.out.println("学号="+sid);
    55. response.setContentType("text/html;charset=UTF-8");
    56. response.setHeader("Cache-Control", "no-cache");
    57. PrintWriter out=null;
    58. out=response.getWriter();
    59. if(studentService.getByStuSid(sid) != null && sid.length() ==12){
    60. out.println("学号已存在");
    61. }else if(sid.length() ==12){
    62. out.println("学号可以使用");
    63. }else {
    64. out.println("学号必须是12位");
    65. }
    66. out.flush();
    67. out.close();
    68. }
    69. //ajax验证教师id
    70. @RequestMapping(value="/existTid",method = RequestMethod.POST)
    71. public void existTid(@RequestParam("tid") String tid,HttpServletResponse response,HttpServletRequest request) throws IOException{
    72. response.setContentType("text/html;charset=UTF-8");
    73. response.setHeader("Cache-Control", "no-cache");
    74. PrintWriter out=null;
    75. out=response.getWriter();
    76. if(teacherService.getByTeaTid(tid) != null && tid.length() <=5){
    77. out.println("教师编号已存在");
    78. }else if(tid.length() <=12){
    79. out.println("教师编号可以使用");
    80. }else {
    81. out.println("教师编号必须小于等于5位");
    82. }
    83. out.flush();
    84. out.close();
    85. }
    86. @RequestMapping(value="/existTime",method = RequestMethod.POST)
    87. public void existTime(@RequestParam("coursetime") String coursetime,@RequestParam("courseweek") String courseweek,
    88. @RequestParam("classroom") String classroom,HttpServletResponse response,HttpServletRequest request) throws IOException{
    89. response.setContentType("text/html;charset=UTF-8");
    90. response.setHeader("Cache-Control", "no-cache");
    91. PrintWriter out=null;
    92. System.out.println("--------------------------");
    93. System.out.println(coursetime+"---"+courseweek+"---"+classroom);
    94. out=response.getWriter();
    95. if(coursePlanService.ajaxGetCoursePlan(coursetime,courseweek,classroom) != null){
    96. out.println("此功能排重正在开发中.....");
    97. }else {
    98. out.println("此功能排重正在开发中.....");
    99. }
    100. out.flush();
    101. out.close();
    102. }
    103. }

    CourseHandler

    1. package net.fuzui.StudentInfo.handler;
    2. import java.util.ArrayList;
    3. import java.util.List;
    4. import javax.servlet.http.HttpServletRequest;
    5. import javax.servlet.http.HttpSession;
    6. import org.springframework.beans.factory.annotation.Autowired;
    7. import org.springframework.stereotype.Controller;
    8. import org.springframework.ui.Model;
    9. import org.springframework.web.bind.annotation.PathVariable;
    10. import org.springframework.web.bind.annotation.RequestMapping;
    11. import org.springframework.web.bind.annotation.RequestMethod;
    12. import org.springframework.web.bind.annotation.RequestParam;
    13. import org.springframework.web.bind.annotation.SessionAttributes;
    14. import com.github.pagehelper.PageHelper;
    15. import com.github.pagehelper.PageInfo;
    16. import net.fuzui.StudentInfo.pojo.Course;
    17. import net.fuzui.StudentInfo.pojo.Teacher;
    18. import net.fuzui.StudentInfo.service.CourseService;
    19. @Controller
    20. @RequestMapping("/CourseHandler")
    21. @SessionAttributes("courseList")
    22. public class CourseHandler {
    23. @Autowired
    24. CourseService courseService;
    25. // 添加课程
    26. @RequestMapping("/addCourse")
    27. public String addCourse(Course course, Model model) {
    28. if (courseService.insertCourse(course) != 0) {
    29. model.addAttribute("course", course);
    30. return "success";
    31. } else {
    32. return "fail";
    33. }
    34. }
    35. public void pageIn(Model model,List list) {
    36. PageInfo page = new PageInfo(list, 5);
    37. model.addAttribute("pageInfo", page);
    38. }
    39. public void queryCou(HttpServletRequest request) {
    40. List courseList = new ArrayList();
    41. courseList = courseService.selectCourseBySql(1,10);
    42. request.setAttribute("courseList", courseList);
    43. }
    44. // 查询课程
    45. @RequestMapping(value = "/query/{pn}", method = RequestMethod.GET)
    46. public String redirect(@RequestParam("serc") String serc, @RequestParam("condition") String condition,
    47. HttpServletRequest request,@PathVariable(value = "pn") String pn,Model model) {
    48. int no = Integer.parseInt(pn);
    49. List courseList = new ArrayList();
    50. PageHelper.startPage(no, 5);
    51. request.setAttribute("serc", serc);
    52. request.setAttribute("condition", condition);
    53. if (serc.equals("all")) {
    54. courseList = courseService.selectCourseBySql(1,10);
    55. pageIn(model, courseList);
    56. request.setAttribute("courseList", courseList);
    57. System.out.println(courseList);
    58. return "admin/queryCourse";
    59. } else if (serc.equals("sid")) {
    60. courseList = courseService.getByCourseCid(1,10,condition);
    61. pageIn(model, courseList);
    62. request.setAttribute("courseList", courseList);
    63. System.out.println("sid");
    64. return "admin/queryCourse";
    65. } else if (serc.equals("nam")) {
    66. courseList = courseService.getByCourseCname(1,10,condition);
    67. pageIn(model, courseList);
    68. request.setAttribute("courseList", courseList);
    69. System.out.println(courseList);
    70. System.out.println("cla");
    71. return "admin/queryCourse";
    72. } else if (serc.equals("col")) {
    73. courseList = courseService.getByCourseCol(1,10,condition);
    74. pageIn(model, courseList);
    75. request.setAttribute("courseList", courseList);
    76. System.out.println(courseList);
    77. System.out.println("col");
    78. return "admin/queryCourse";
    79. } else if (serc.equals("type")) {
    80. courseList = courseService.getByCourseType(1,10,condition);
    81. pageIn(model, courseList);
    82. request.setAttribute("courseList", courseList);
    83. System.out.println(courseList);
    84. System.out.println("pro");
    85. return "admin/queryCourse";
    86. } else {
    87. courseList = courseService.selectCourseBySql(1,10);
    88. pageIn(model, courseList);
    89. request.setAttribute("courseList", courseList);
    90. return "admin/queryCourse";
    91. }
    92. }
    93. //删除学生
    94. @RequestMapping(value = "/delete/{cid}", method = RequestMethod.GET)
    95. public String deleteStudent(@PathVariable(value = "cid") String cid, HttpServletRequest request) {
    96. if (courseService.deleteCourse(cid) != 0) {
    97. System.out.println("success");
    98. queryCou(request);
    99. return "success";
    100. } else {
    101. System.out.println("fail");
    102. return "fail";
    103. }
    104. }
    105. //跳转到queryCourse页面
    106. @RequestMapping(value = "/finalPage", method = RequestMethod.GET)
    107. public String finalPage(HttpSession httpSession,HttpServletRequest request) {
    108. Object admin = request.getSession().getAttribute("courseList");
    109. System.out.println(admin+"111111111111111111111111111111111111111111111111111111111111111111111111111");
    110. return "admin/queryCourse";
    111. }
    112. /**
    113. * 修改课程定位
    114. * @param cid
    115. * @param model
    116. * @return
    117. */
    118. @RequestMapping(value = "/moditystu/{cid}", method = RequestMethod.GET)
    119. public String editPre(@PathVariable("cid") String cid, HttpServletRequest request) {
    120. List courseList = new ArrayList();
    121. courseList = courseService.getByCourseCid(1,10,cid);
    122. request.setAttribute("courseList", courseList);
    123. return "admin/modiCourse";
    124. }
    125. //修改课程信息
    126. @RequestMapping(value = "/moditystud/{cid}", method = RequestMethod.GET)
    127. public String update(@PathVariable("cid") String cid, Course course, Model model) {
    128. if (courseService.modifyCourse(course) != 0) {
    129. return "success";
    130. } else {
    131. return "fail";
    132. }
    133. }
    134. //跳转到queryCourse页面
    135. @RequestMapping("/managecou/{pn}")
    136. public String manageCourse(HttpServletRequest request,@PathVariable(value = "pn") String pn,Model model) {
    137. int no = Integer.parseInt(pn);
    138. List courseList = new ArrayList();
    139. PageHelper.startPage(no, 5);
    140. courseList = courseService.selectCourseBySql(1,10);
    141. pageIn(model, courseList);
    142. request.setAttribute("courseList", courseList);
    143. return "admin/queryCourse";
    144. }
    145. }

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

  • 相关阅读:
    【C++进阶之路】第九篇:特殊类设计
    使用js原生customElements.define()API 实现类似godot游戏引擎的colorRect类
    19.删除链表的倒数第 N 个节点
    100张照片带你了解澳大利亚
    电子学会青少年软件编程 Python编程等级考试二级真题解析(判断题)2021年12月
    Go中的channel
    synchronized详解
    java企业数据管理系统
    [C++随笔录] stack && queue使用
    BSA-PEI,牛血清白蛋白-聚乙烯亚胺,BSA-聚乙烯亚胺的保存
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/126651944