基于javaweb+mysql的ssm选课管理系统(java+ssm+layui+jsp+jquery+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM选课管理系统(java+ssm+layui+jsp+jquery+mysql)
项目介绍
基于SSM的选课管理系统
管理员:个人申心、公告信息管理、学生管理、教师管理、院系管理、专业管理、班级管理、课程信息管理、学生选课管理、课程成绩管理
学生:个人中心、公告信息管理、课程信息管理、学生选课管理、课程成绩管理
教师:个人中心、公告信息管理、课程信息管理、学生选课管理课程成绩管理
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 4.数据库:MySql 5.7/8.0版本均可; 5.是否Maven项目:是;
技术栈
后端:SSM(Spring+SpringMVC+Mybatis) 前端:JSP+CSS+JS+JQUERY+Layui
使用说明
项目运行: 1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
return "studentInfo";
@GetMapping("/getCode")
@ResponseBody
public Object getCode(HttpServletRequest request) {
/* 生成验证码字符串 */
String verifyCode = VerifyCodeUtil.generateVerifyCode(4);
String uuid = UUIDUtil.GeneratorUUIDOfSimple();
HttpSession session = request.getSession();
session.setAttribute(uuid,verifyCode); //将验证码与生成的uuid绑定在一起
System.out.println("生成的验证码为:" + verifyCode);
int width = 111,height = 36;
try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
VerifyCodeUtil.outputImage(width, height, stream, verifyCode);
//public String error(){
// return "error";
//}
@GetMapping("/info")
@PreAuthorize("hasAuthority('student')")
public String info(){
return "studentInfo";
@GetMapping("/getCode")
@ResponseBody
public Object getCode(HttpServletRequest request) {
/* 生成验证码字符串 */
String verifyCode = VerifyCodeUtil.generateVerifyCode(4);
map.put("totalCount" , pageInfo.getTotal()); //总条数
map.put("currentPage" , page); //当前页数。
map.put("data" , pageInfo.getList()); //获得的数据量
map.put("tCase",username);
return JSON.toJSON(map);
}catch(Exception e){
e.printStackTrace();
return Msg.fail();
//测试。
@PostMapping("cc")
public Object cc(){
public Object getCode(HttpServletRequest request) {
/* 生成验证码字符串 */
String verifyCode = VerifyCodeUtil.generateVerifyCode(4);
String uuid = UUIDUtil.GeneratorUUIDOfSimple();
HttpSession session = request.getSession();
session.setAttribute(uuid,verifyCode); //将验证码与生成的uuid绑定在一起
System.out.println("生成的验证码为:" + verifyCode);
int width = 111,height = 36;
try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
VerifyCodeUtil.outputImage(width, height, stream, verifyCode);
return Msg.msg("data",new ImgVO("data:image/gif;base64,"+ Base64Utils.encodeToString(stream.toByteArray()),uuid));
}catch(Exception e){
if(e instanceof DataIntegrityViolationException){
map.put("msg","该课程已经被抢完啦。");
}else{
map.put("msg","出现其他异常,选课失败!");
map.put("flag",false);
return JSON.toJSON(map);
/**
* 退课
* @param courseId
* @param username
return "success";
@GetMapping("/manager")
@PreAuthorize("hasAuthority('admin')")
public String manager(){
return "manager";
//@RequestMapping("/error")
//public String error(){
// return "error";
//}
@GetMapping("/info")
@PreAuthorize("hasAuthority('student')")
public String info(){
return "studentInfo";
@GetMapping("/getCode")
@PostMapping("choose")
@PreAuthorize("hasAuthority('student')")
public Object chooseCourse(@RequestParam("courseId") Integer courseId ,
@RequestParam("username") String username){
Map<String,Object> map = new HashMap<>();
try{
return userCourseService.chooseCourse(courseId , username);
}catch(Exception e){
if(e instanceof DataIntegrityViolationException){
map.put("msg","该课程已经被抢完啦。");
@PreAuthorize("hasAuthority('admin') or hasAuthority('student')")
public Object studentInfo(@RequestParam(value = "page", defaultValue = "1") int page ,
@RequestParam(value = "limit", defaultValue = "10") int limit ,
@RequestParam("username")String username){
try{
Map<String,Object> map = new HashMap<>();
PageHelper.startPage(page , limit);
List<SelectableCourse> list = selectableCourseDAO.selectByUser(username);
if(list == null){
return Msg.fail();
//System.out.println("=="+username+"==");
PageInfo<SelectableCourse> pageInfo = new PageInfo<>(list);
* @param page
* @param limit
* @param username
* @return
*/
@PostMapping("studentInfo")
@PreAuthorize("hasAuthority('admin') or hasAuthority('student')")
public Object studentInfo(@RequestParam(value = "page", defaultValue = "1") int page ,
@RequestParam(value = "limit", defaultValue = "10") int limit ,
@RequestParam("username")String username){
try{
@RequestMapping("/login")
public String login(){
return "login";
@GetMapping("/")
public String index() {
return "success";
@GetMapping("/manager")
@PreAuthorize("hasAuthority('admin')")
public String manager(){
return "manager";
//@RequestMapping("/error")
@Api
public class UserCourseController{
@Autowired
UserCourseService userCourseService;
@Autowired
SelectableCourseDAO selectableCourseDAO;
/**
* 选课
* @param courseId
* @param username
* @return
*/
return JSON.toJSON(map);
/**
* 退课
* @param courseId
* @param username
* @return
*/
@PostMapping("cancel")
@PreAuthorize("hasAuthority('student')")
public Object cancelCourse(@RequestParam("courseId") Integer courseId ,
@RequestParam("username") String username){
登录管理控制层:
@Controller
@Api
public class LoginController{
@Autowired
AdminService adminService;
@Autowired
UserService userService;
@RequestMapping("/login")
public String login(){
return "login";
@GetMapping("/")
public String addCourse(){
return "addCourse";
登录管理控制层:
@Controller
@Api
public class LoginController{
@Autowired
AdminService adminService;
@Autowired
UserService userService;
@RequestMapping("/login")
public String login(){
return "login";
* @param courseId
* @param username
* @return
*/
@PostMapping("choose")
@PreAuthorize("hasAuthority('student')")
public Object chooseCourse(@RequestParam("courseId") Integer courseId ,
@RequestParam("username") String username){
Map<String,Object> map = new HashMap<>();
try{
return userCourseService.chooseCourse(courseId , username);
@Autowired
AdminService adminService;
/**
* Excel表格导出接口
* http://localhost:8080/ExcelDownload
* @param response response对象
*/
@GetMapping("/ExcelDownload")
@PreAuthorize("hasAuthority('admin')")
public void excelDownload(HttpServletResponse response) throws IOException{
adminService.excelOut(response);
String uuid = UUIDUtil.GeneratorUUIDOfSimple();
HttpSession session = request.getSession();
session.setAttribute(uuid,verifyCode); //将验证码与生成的uuid绑定在一起
System.out.println("生成的验证码为:" + verifyCode);
int width = 111,height = 36;
try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
VerifyCodeUtil.outputImage(width, height, stream, verifyCode);
return Msg.msg("data",new ImgVO("data:image/gif;base64,"+ Base64Utils.encodeToString(stream.toByteArray()),uuid));
} catch (IOException e) {
e.printStackTrace();
//@RequestMapping("/error")
//public String error(){
// return "error";
//}
@GetMapping("/info")
@PreAuthorize("hasAuthority('student')")
public String info(){
return "studentInfo";
@GetMapping("/getCode")
@ResponseBody
public Object getCode(HttpServletRequest request) {