文章目錄
- 01 完整源碼下載下傳
- 02 系統概述
- 03 開發工具及技術選型
- 04 運作環境
- 05 使用者分析
- 06 功能分析
- 07 資料庫設計
- 08 項目工程結構及說明
- 09 部分功能展示及源碼
- 9.1 管理者端--首頁
- 9.2 管理者端--專業管理
- 9.3 管理者--課程管理
- 9.4 管理者端--統計資訊
- 9.5 普通使用者端--基本資訊
- 9.6 普通使用者端--已選課程
- 9.7 使用者登入
- 10 運作教程
01 完整源碼下載下傳
微信搜尋關注公衆号【IT學長】
,回複“
20221022
”下載下傳高校選課系統源代碼
02 系統概述
學生選課系統是一個學校不可缺少的部分,它能為使用者提供充足的資訊和快捷的查詢手段。管理者可以通過超級使用者身份登入,對系統進行全面的管理。學生可以登入系統進行個人資訊查詢、網上選課等等。
本文設計的高校選課系統是在J2EE平台下開發完成的,采用了B/S模式、MySQL資料庫和Tomcat伺服器。其具有使用者界面簡潔友好,操作簡單易用,運作穩定可靠,易維護,可擴充等特點,基本達到了設計要求,對同類系統的設計與實作具有一定的參考價值。
03 開發工具及技術選型
- 資料表現層:Jsp+JavaScript+CSS
- 業務邏輯層:Java+Struts
- 資料持久層:MySQL+Hibernate
- 開發工具:IDEA / Eclipse
04 運作環境
JDK1.8 + Tomcat9.0+ MySQL5.7
05 使用者分析
本系統主要使用人群為系統管理者、普通讀者。
- 系統管理者:管理整個系統的各項功能,如:專業管理、課程管理、資訊統計。
- 普通讀者:查詢基本資訊、選擇新課程、查詢已選課程、修改登入密碼。
06 功能分析
系統管理者:
- 專業管理。 清單顯示專業編号、專業名稱、開設年份、專業學制、是否結業等專業資訊。點選添加新專業按鈕,填寫入學年份、專業名稱、學制錄入新專業。
- 課程管理。 清單顯示專業名稱、課程名稱 、上課時間、上課地點、課程學分、授課教師、學生是否可選等課程資訊。點選增加新課程按鈕,填寫專業、課程名稱、上課時間、上課地點、課程學分、課程介紹、授課教師、教師介紹錄入新課程。輸入專業、教師名稱、課程名稱進行條件搜尋。
- 統計資訊。 統計每個專業下學生選課情況,并且可以導出PDF、Excel文檔。
- 修改登入密碼。 對個人的登入密碼進行修改操作。
- 退出系統。 退出目前登入使用者,跳轉待登入界面。
普通讀者:
- 查詢基本資訊。 對專業、入學年份、學制、學号、出生日期、聯系電話、現住址、家庭位址等基本資訊進行查詢。
- 選擇新課程。 對自己專業下的課程進行選課。
- 查詢已選課程。 對已經選擇的課程進行查詢,按清單顯示課程名稱、授課教師、學分、上課時間、上課地點等資訊。
- 修改登入密碼。 對個人的登入密碼進行修改操作。
- 退出系統。 退出目前登入使用者,跳轉待登入界面。
07 資料庫設計
tb_course: 用于存儲課程資訊
字段名稱 | 類型 | 是否為NULL | 是否主鍵 | 說明 |
id | int | 否 | 是 | 課程編号 |
name | varchar | 否 | 否 | 課程名稱 |
schooltime | varchar | 否 | 否 | 上課時間 |
addr | varchar | 否 | 否 | 上課地點 |
credit | decimal | 否 | 否 | 課程學分 |
courseInfo | varchar | 否 | 否 | 課程介紹 |
teacherName | varchar | 否 | 否 | 老師姓名 |
teacherInfo | varchar | 否 | 否 | 老師介紹 |
isFinish | bit | 否 | 否 | 是否可選 |
specialtyId | int | 否 | 否 | 所屬專業編号 |
tb_specialty: 用于存儲專業資訊
字段名稱 | 類型 | 是否為NULL | 是否主鍵 | 說明 |
id | int | 否 | 是 | 專業編号 |
enterYear | varchar | 否 | 否 | 開設年份 |
name | varchar | 否 | 否 | 專業名稱 |
langthYear | varchar | 否 | 否 | 專業學制 |
isFinish | bit | 否 | 否 | 是否結業 0:未結業 1:結業 |
tb_stucourse: 用于映射學生與課程之間的關系
字段名稱 | 類型 | 是否為NULL | 是否主鍵 | 說明 |
id | int | 否 | 是 | 主鍵編号 |
stuID | int | 否 | 否 | 學生編号 |
courseID | int | 否 | 否 | 課程編号 |
tb_stuuser: 用于存儲學生資訊
字段名稱 | 類型 | 是否為NULL | 是否主鍵 | 說明 |
id | int | 否 | 是 | 學生編号 |
stuName | varchar | 否 | 否 | 學生姓名 |
stuNo | varchar | 否 | 否 | 學生學号 |
specialtyId | int | 否 | 否 | 學生所學專業編号 |
stuSex | varchar | 否 | 否 | 學生性别 |
birthday | varchar | 否 | 否 | 學生出生年月日 |
homeAddr | varchar | 否 | 否 | 學生家庭位址 |
tel | varchar | 否 | 否 | 學生電話 |
addr | varchar | 否 | 否 | 學生目前居住位址 |
tb_userlogin: 用于存儲使用者資訊
字段名稱 | 類型 | 是否為NULL | 是否主鍵 | 說明 |
id | int | 否 | 是 | 使用者編号 |
loginName | varchar | 否 | 否 | 使用者名 |
pwd | varchar | 否 | 否 | 密碼 |
type | varchar | 否 | 否 | 使用者類型 1:管理者 2:學生 |
varchar | 否 | 否 | 郵箱 |
08 項目工程結構及說明

目錄 | 說明 |
com.cya.action | 存放action類,接收前端發來的請求,并将響應結果傳回給前端 |
com.cya.dao | 存放dao層接口 |
com.cya.dto | 存放實體類 |
com.cya.tools | 存放工具類 |
WebContent/images | 存放項目所需要的圖檔檔案 |
WebContent/manager | 存放管理者端Jsp檔案 |
WebContent/stu | 存放普通使用者端(學生)Jsp檔案 |
09 部分功能展示及源碼
9.1 管理者端–首頁
9.2 管理者端–專業管理
專業清單:
添加新專業:
部分源碼:
package com.cya.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.actions.DispatchAction;
import com.cya.dao.ISpecialtyDao;
import com.cya.dto.Specialty;
/**
* @author 公衆号【IT學長】
*/
public class SpecialtyAction extends DispatchAction {
private ISpecialtyDao specialtyDao;
public void setSpecialtyDao(ISpecialtyDao specialtyDao) {
this.specialtyDao = specialtyDao;
}
public ActionForward insert(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaActionForm specialtyForm = (DynaActionForm) form;
Specialty specialty = new Specialty();
specialty.setIsFinish(false); // 設定是否結業,預設為否
specialty.setName(specialtyForm.getString("name"));
specialty.setEnterYear(specialtyForm.getString("enterYear"));
specialty.setLangthYear(specialtyForm.getString("langthYear"));
specialtyDao.insert(specialty);
findAll(mapping, specialtyForm, request, response);
return mapping.findForward("showSpecialty");
}
/**
* 将專業設定為已結業
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward updateIsFinish(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Integer id = Integer.valueOf(request.getParameter("id"));
specialtyDao.updateIsFinish(id);
return findAll(mapping, form, request, response);
}
public ActionForward findAll(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List list = specialtyDao.findByAll();
request.setAttribute("list", list);
return mapping.findForward("showSpecialty");
}
}
9.3 管理者–課程管理
課程清單:
添加新課程:
部分源碼:
package com.cya.action;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.actions.DispatchAction;
import com.cya.dao.ICourseDao;
import com.cya.dao.ISpecialtyDao;
import com.cya.dto.Course;
import com.cya.dto.Specialty;
/**
* @author 公衆号【IT學長】
*/
public class CourseAction extends DispatchAction {
private ISpecialtyDao specialtyDao;
private ICourseDao courseDao;
/**
* @param specialtyDao the specialtyDao to set
*/
public void setSpecialtyDao(ISpecialtyDao specialtyDao) {
this.specialtyDao = specialtyDao;
}
/**
* @param courseDao the courseDao to set
*/
public void setCourseDao(ICourseDao courseDao) {
this.courseDao = courseDao;
}
public ActionForward insert(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaActionForm courseForm = (DynaActionForm) form;
Course course = new Course();
course.setName(courseForm.getString("name"));
course.setSchooltime(courseForm.getString("schooltime"));
course.setAddr(courseForm.getString("addr"));
course.setCredit((Short)courseForm.get("credit"));
course.setCourseInfo(courseForm.getString("courseInfo"));
course.setTeacherName(courseForm.getString("teacherName"));
course.setTeacherInfo(courseForm.getString("teacherInfo"));
course.setIsFinish(true); //是否可以選課,預設為可以
course.setSpecialtyId((Integer)courseForm.get("specialtyId"));
courseDao.insert(course);
return findBySearch(mapping, courseForm, request, response);
}
public ActionForward updateIsFinish(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Integer id = Integer.valueOf(request.getParameter("id"));
courseDao.updateIsFinish(id);
return courseInfo(mapping, form, request, response);
}
public ActionForward findBySearch(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List<Specialty> sList = specialtyDao.findByAll();
Map<String,String> map = new HashMap<String,String>();
if(request.getParameter("specialtyId")!=null&&!request.getParameter("specialtyId").equals("-1")){
map.put("specialtyId", request.getParameter("specialtyId"));
}
if(request.getParameter("name")!=null&&!request.getParameter("name").equals("")){
map.put("name", request.getParameter("name"));
}
if(request.getParameter("teacherName")!=null&&!request.getParameter("teacherName").equals("")){
map.put("teacherName", request.getParameter("teacherName"));
}
List<Object> clist = courseDao.findBySearch(map);
request.setAttribute("sList", sList);
request.setAttribute("cList", clist);
return mapping.findForward("showCourse");
}
/**
* 進入添加新課程頁面
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward showInsert(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List<Specialty> list = specialtyDao.findByAll();
request.setAttribute("list", list);
return mapping.findForward("addCourse");
}
public ActionForward courseInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Integer id = Integer.valueOf(request.getParameter("id"));
Course course = courseDao.findByID(id);
Specialty specialty = specialtyDao.findById(course.getSpecialtyId());
request.setAttribute("course", course);
request.setAttribute("specialty", specialty);
return mapping.findForward("courseInfo");
}
}
9.4 管理者端–統計資訊
資訊清單:
選課人員清單:
導出PDF文檔:
導出Excel文檔:
9.5 普通使用者端–基本資訊
部分源碼:
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
<title>welcome.jsp</title>
<link rel="stylesheet" type="text/css" href="images/style.css">
</head>
<body>
<table width="845" border="0" cellspacing="0" align="center">
<tr>
<td height="124" colspan="2" background="images/topU.gif"> </td>
</tr>
<tr>
<td width="145" height="500" align="left" valign="top" bgcolor="#E4F0D8">
<jsp:include page="left.jsp"/>
</td>
<td width="700" align="left" valign="top">
<table cellspacing="0" width="600px" align="center">
<tr>
<td height="20" colspan="2"></td>
</tr>
<tr>
<td width="14" background="images/jiantou.jpg"> </td>
<td width="585"><span class="STYLE2">目前位置:</span>使用者基本資訊</td>
</tr>
<tr>
<td height="8" colspan="2"></td>
</tr>
<tr>
<td height="3" colspan="2" bgcolor="#b1de69"></td>
</tr>
<tr>
<td height="20" colspan="2"></td>
</tr>
</table>
<table width="500" align="center" cellspacing="0">
<tr>
<td height="30" align="right" bgcolor="#e4f0d8" class="td0" width="114">專業名稱:</td>
<td align="right" bgcolor="#e4f0d8" class="td0" width="10"> </td>
<td width="9" height="30" align="left" bgcolor="#e4f0d8" class="td0"> </td>
<td width="357" align="left" bgcolor="#e4f0d8" class="td0">${specialty.name}</td>
</tr>
<tr>
<td height="30" align="right" class="td1">入學年份:</td>
<td height="30" align="right" class="td1"> </td>
<td height="30" class="td2"> </td>
<td height="30" class="td1">${specialty.enterYear}年</td>
</tr>
<tr>
<td height="30" align="right" class="td1">學制:</td>
<td height="30" align="right" class="td1"> </td>
<td height="30" class="td2"> </td>
<td height="30" class="td1">${specialty.langthYear}年</td>
</tr>
<tr>
<td height="30" align="right" class="td1">姓名:</td>
<td height="30" align="right" class="td1"> </td>
<td height="30" class="td2"> </td>
<td height="30" class="td1">${stuUser.stuName}</td>
</tr>
<tr>
<td height="30" align="right" class="td1">學号:</td>
<td height="30" align="right" class="td1"> </td>
<td height="30" class="td2"> </td>
<td height="30" class="td1">${stuUser.stuNo}</td>
</tr>
<tr>
<td height="30" align="right" class="td1">性别:</td>
<td height="30" align="right" class="td1"> </td>
<td height="30" class="td2"> </td>
<td height="30" class="td1">${stuUser.stuSex}</td>
</tr>
<tr>
<td height="30" align="right" class="td1">出生日期:</td>
<td height="30" align="right" class="td1"> </td>
<td height="30" class="td2"> </td>
<td height="30" class="td1">${stuUser.birthday}</td>
</tr>
<tr>
<td height="30" align="right" class="td1">聯系電話:</td>
<td height="30" align="right" class="td1"> </td>
<td height="30" class="td2"> </td>
<td height="30" class="td1">${stuUser.tel}</td>
</tr>
<tr>
<td height="30" align="right" class="td1">現住址:</td>
<td height="30" align="right" class="td1"> </td>
<td height="30" class="td2"> </td>
<td height="30" class="td1">${stuUser.addr}</td>
</tr>
<tr>
<td height="30" align="right" class="td1">家庭位址:</td>
<td height="30" align="right" class="td1"> </td>
<td height="30" class="td2"> </td>
<td height="30" class="td1">${stuUser.homeAddr}</td>
</tr>
</table>
<p>
</td>
</tr>
<tr>
<td style="font-weight: bold;color: green;font-size: 18px;" height="85" colspan="2" align="center" background="images/bottomU.gif"> 【IT學長】,幾十套畢業設計項目源碼、百G Java面試題</td>
</tr>
</table>
</body>
</html:html>
9.6 普通使用者端–已選課程
部分源碼:
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
<title>selected.jsp</title>
<link rel="stylesheet" type="text/css" href="images/style.css">
</head>
<body>
<table width="845" cellspacing="0" align="center">
<tr>
<td height="124" colspan="2" background="images/topU.gif"> </td>
</tr>
<tr>
<td width="150" height="500" align="left" valign="top" bgcolor="#E4F0D8">
<jsp:include page="left.jsp"/>
</td>
<td align="left" valign="top">
<table cellspacing="0" width="600px" align="center">
<tr>
<td height="20" colspan="2"></td>
</tr>
<tr>
<td width="14" background="images/jiantou.jpg"> </td>
<td width="585"><span class="STYLE2">目前位置:</span>查詢已選課程</td>
</tr>
<tr>
<td height="8" colspan="2"></td>
</tr>
<tr>
<td height="3" colspan="2" bgcolor="#b1de69"></td>
</tr>
<tr>
<td height="20" colspan="2"></td>
</tr>
</table>
<table width="500" align="center" cellspacing="0">
<tr>
<td height="30" align="center" class="td0"><strong>課程名稱</strong></td>
<td align="center" class="td0"><strong>授課教師</strong></td>
<td align="center" class="td0"><strong>學分</strong></td>
<td align="center" class="td0"><strong>上課時間</strong></td>
<td align="center" class="td0"><strong>上課地點</strong></td>
</tr>
<logic:iterate id="list" name="list">
<tr>
<td height="30" align="center" class="td1">
<html:link page="/stuUser.do?method=courseInfo&id=${list[1].id}&path=selected">
${list[1].name}</html:link></td>
<td align="center" class="td1">${list[1].teacherName}</td>
<td align="center" class="td1">${list[1].credit }</td>
<td align="center" class="td1">${list[1].schooltime}</td>
<td align="center" class="td1">${list[1].addr}</td>
</tr>
</logic:iterate>
</table>
</td>
</tr>
<tr>
<td style="font-weight: bold;color: green;font-size: 18px;" height="85" colspan="2" align="center" background="images/bottomU.gif"> 【IT學長】,幾十套畢業設計項目源碼、百G Java面試題</td>
</tr>
</table>
</body>
</html:html>
9.7 使用者登入
部分源碼:
package com.cya.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import com.cya.dao.ISpecialtyDao;
import com.cya.dao.IStuUserDao;
import com.cya.dao.IUserLoginDao;
import com.cya.dto.Specialty;
import com.cya.dto.StuUser;
import com.cya.dto.UserLogin;
/**
* @author 公衆号【IT學長】
*/
public class UserLoginAction extends Action {
private IUserLoginDao userLoginDao;
private IStuUserDao stuUserDao;
private ISpecialtyDao specialtyDao;
public void setSpecialtyDao(ISpecialtyDao specialtyDao) {
this.specialtyDao = specialtyDao;
}
public void setStuUserDao(IStuUserDao stuUserDao) {
this.stuUserDao = stuUserDao;
}
public void setUserLoginDao(IUserLoginDao userLoginDao) {
this.userLoginDao = userLoginDao;
}
/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaActionForm userLoginForm = (DynaActionForm) form;
UserLogin userLogin = userLoginDao.findbyNameAndPwd(userLoginForm
.getString("loginName"), userLoginForm.getString("pwd"));
if (userLogin == null) {
request.setAttribute("error", "使用者登入失敗,使用者名或密碼不正确!");
return mapping.findForward("index");
} else {
request.getSession().setAttribute("loginName",
userLogin.getLoginName());
request.getSession().setAttribute("id", userLogin.getId());
if (userLogin.getType().equals("1")) {
System.out.println("管理者登入");
return mapping.findForward("manager");
} else {
// 判斷學生有沒有填寫過基本資訊
StuUser stuUser = stuUserDao.findById(userLogin.getId());
if (stuUser == null) {
List<Specialty> list = specialtyDao.findStuByAll();
request.setAttribute("list", list);
return mapping.findForward("addStuInfo");
} else {
Specialty specialty = specialtyDao.findById(stuUser
.getSpecialtyId());
request.setAttribute("specialty", specialty);
request.setAttribute("stuUser", stuUser);
return mapping.findForward("welcome");
}
}
}
}
}
10 運作教程
- 下載下傳安裝Java(JDK1.8)、MySQL(MySQL5.7)、Tomcat(Tomcat9.0)
- 下載下傳本系統源代包
- 将源碼包中
導入MySQLdb_course_selection.sql
- 将下載下傳好的源碼導入Eclipse/IDEA開發工具中
- 修改
courseSelection/WebContent/applicationContext.xml
6. 配置Tomcat
7. 啟動服務,浏覽器輸入
http://localhost:8080/courseSelection