基于javaweb的SSM+Maven在线选课管理系统(java+ssm+jsp+bootstrap+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

300023112402

310023112402

330023112402

340023112402

350023112402

360023112402

基于javaweb的SSM+Maven在线选课管理系统(java+ssm+jsp+bootstrap+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.是否Maven项目:是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7版本;

软件架构

系统是一个基于SSM框架实现的项目,采用当前最流行的框架Spring-SpringMVC-MyBatis设计。 前端:HTML+BootStrap+CSS+Javascript  后端:Spring+SpringMVC+mybatis

使用说明

1.使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,下载所需jar包; 2.使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 3.将项目中db.properties配置文件中的数据库配置改为自己的配置 4.配置tomcat,然后运行项目,输入localhost:8080/xxx登录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
	return SKIP_BODY;
}

private String append(String url, String key, int value) {
return append(url, key, String.valueOf(value));
}
/**
* 为url 参加参数对儿
*/
private String append(String url, String key, String value) {
if (url == null || url.trim().length() == 0) {
return "";
}
if (url.indexOf("?") == -1) {
url = url + "?" + key + "=" + value;
} else {
if (url.endsWith("?")) {
url = url + key + "=" + value;
} else {
url = url + "&" + key + "=" + value;
}
}
return url;
}
/**
* 为url 添加翻页请求参数
*/
private String resolveUrl(String url,
javax.servlet.jsp.PageContext pageContext) throws JspException {
Map params = pageContext.getRequest().getParameterMap();
for (Object key : params.keySet()) {
if ("page".equals(key) || "rows".equals(key)){
continue;
}
Object value = params.get(key);
if (value == null){
continue;
}
if (value.getClass().isArray()) {
url = append(url, key.toString(), ((String[]) value)[0]);
} else if (value instanceof String) {
url = append(url, key.toString(), value.toString());
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
        } finally {
req.getSession().setAttribute("msg", msg);
return "redirect:/chooseManage";
}
}


@RequestMapping("/addChoose")
public String addChoose(HttpServletRequest req, @RequestParam String stuId, @RequestParam String clzId) {
String msg = null;
try {
Integer cId = Integer.parseInt(clzId);
Student s = adminService.getStudentById(stuId);
Course c = adminService.getCourseById(cId);
if (s != null && c != null) {
if(c.getAmount()>c.getSelected()) {
int rst = studentService.selectCource(stuId, cId);
if (rst==0) {
msg = "添加成功";
} else if(rst==1){
msg = "已经选过此课!";
} else if(rst==2){
msg="该课程已选满!";
}else{
msg="未知错误!";
}
}
}else{
msg="添加失败";
}
} catch (Exception e) {
msg = "添加失败";
e.printStackTrace();
} finally {
req.getSession().setAttribute("msg", msg);
return "redirect:/chooseManage";
}
}

}
package cn.wxj.controller;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
                req.getSession().setAttribute("id",username);
return "redirect:adminIndex";
}
}
return "adminLogin";
}

}
package cn.wxj.controller;





@Controller
public class SelectController {

@Autowired
private IStudentService studentService;

@Autowired
private IStudyService studyService;

@Autowired
private IClzService clzService;


@RequestMapping("/selectClz")
public String selectClz(HttpServletRequest req) {
String sId = (String) req.getSession().getAttribute("userId");
Course c = (Course) req.getSession().getAttribute("course");

Integer cId = c.getId();

String msg = null;
int rst = studentService.selectCource(sId, cId);
if (rst==0) {
msg = "选课成功!";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
    			
try {
FileUtils.writeByteArrayToFile(new File(dir,tempfilename), file.getBytes());
} catch (IOException e) {

e.printStackTrace();
}
course.setImgurl("/upload/imgurl/"+year_moth+"/"+tempfilename); //设置图片所在路径

}
course.setName(req.getParameter("name"));
course.setSelected(0);
course.setAmount(Integer.parseInt(req.getParameter("amount")));
course.setBelong(req.getParameter("belong"));
course.setCredit(Integer.parseInt(req.getParameter("credit")));
course.setPlace(req.getParameter("place"));
course.setDetail(req.getParameter("detail"));
course.setTime(req.getParameter("time"));
if (adminService.addCourse(course)) {
msg = "添加成功";
} else {
msg = "添加失败";
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (Exception e) {
msg = "添加失败";
} finally {
req.getSession().setAttribute("msg", msg);
return "redirect:/courseManage";
}
}

@RequestMapping("adminDelCourse")
public String delCourse(@RequestParam String id, HttpServletRequest req) {
adminService.delCourse(Integer.parseInt(id));
req.getSession().setAttribute("msg", "删除成功");
return "redirect:/courseManage";
}

@RequestMapping(value = "/changeCourse", method = RequestMethod.GET)
public String changeCourse(@RequestParam String id, HttpServletRequest req) {
Course course = adminService.getCourseById(Integer.parseInt(id));
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
        Integer stdId = Integer.parseInt(id);
StudyInfo info = adminService.getStudyById(stdId);
Course c = adminService.getCourseById(info.getC_id());
c.setSelected(c.getSelected() - 1);
adminService.updateCourse(c);
adminService.delStudyInfo(stdId);
msg = "删除成功";
} catch (Exception e) {
msg = "删除失败";
e.printStackTrace();
} finally {
req.getSession().setAttribute("msg", msg);
return "redirect:/chooseManage";
}
}


@RequestMapping("/addChoose")
public String addChoose(HttpServletRequest req, @RequestParam String stuId, @RequestParam String clzId) {
String msg = null;
try {
Integer cId = Integer.parseInt(clzId);
Student s = adminService.getStudentById(stuId);
Course c = adminService.getCourseById(cId);
if (s != null && c != null) {
if(c.getAmount()>c.getSelected()) {
int rst = studentService.selectCource(stuId, cId);
if (rst==0) {
msg = "添加成功";
} else if(rst==1){
msg = "已经选过此课!";
} else if(rst==2){
msg="该课程已选满!";
}else{
msg="未知错误!";
}
}
}else{
msg="添加失败";
}
} catch (Exception e) {
msg = "添加失败";
e.printStackTrace();
} finally {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 */
private String append(String url, String key, String value) {
if (url == null || url.trim().length() == 0) {
return "";
}
if (url.indexOf("?") == -1) {
url = url + "?" + key + "=" + value;
} else {
if (url.endsWith("?")) {
url = url + key + "=" + value;
} else {
url = url + "&" + key + "=" + value;
}
}
return url;
}
/**
* 为url 添加翻页请求参数
*/
private String resolveUrl(String url,
javax.servlet.jsp.PageContext pageContext) throws JspException {
Map params = pageContext.getRequest().getParameterMap();
for (Object key : params.keySet()) {
if ("page".equals(key) || "rows".equals(key)){
continue;
}
Object value = params.get(key);
if (value == null){
continue;
}
if (value.getClass().isArray()) {
url = append(url, key.toString(), ((String[]) value)[0]);
} else if (value instanceof String) {
url = append(url, key.toString(), value.toString());
}
}
return url;
}
public String getBean() {
return bean;
}
public void setBean(String bean) {
this.bean = bean;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {


项目链接:
https://javayms.github.io?id=161422282105200cq
https://javayms.pages.dev?id=161422282105200cq