作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
本项目分为管理员、教师、学生三种角色;
管理员角色包含以下功能:
管理员登录,学院管理,专业管理,班级管理,学科管理,学生管理,教师管理等功能。 教师角色包含以下功能:教师登录,成绩管理,学生信息查询等功能。
学生角色包含以下功能:
学生角色登录,成绩查询,个人信息修改,密码修改等功能。
环境需要
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/8.0版本均可;
6.是否Maven项目:否;
技术栈
1. 后端:mysql+Spring+hibernate+Struts 2
2. 前端:JSP+CSS+JavaScript+bootstrap+jquery
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目;
3. 将项目中config/jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入http://localhost:8080/xsxx 登录
运行截图
管理员角色
教师角色
学生角色
相关代码
CjAction
package com.my.pro.action;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.my.pro.utils.Pager;
import com.my.pro.utils.UserUtils;
import com.opensymphony.xwork2.ModelDriven;
import java.util.*;
import com.my.pro.model.*;
import com.my.pro.dao.*;
import com.my.pro.service.*;
/**
* @ClassName:
* @Description:
* @author administrator
*
*/
@Controller("cjAction")
@Scope("prototype")
public class CjAction extends BaseAction implements ModelDriven<Cj>{
private static final long serialVersionUID = 1L;
//==========model==============
private Cj cj;
@Override
public Cj getModel() {
if(cj==null) cj = new Cj();
return cj;
}
//==========model==============
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private CjService cjService;
@Autowired
private XkService xkService;
//依赖注入 end dao/service/===
//-------------------------华丽分割线---------------------------------------------
//============自定义参数start=============
//============自定义参数end=============
//-------------------------华丽分割线---------------------------------------------
//============文件上传start=======================================================
@Autowired
private UserService userService;
private String code;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
private File file;
//提交过来的file的名字
private String fileFileName;
//提交过来的file的MIME类型
private String fileContentType;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
//============文件上传end=========================================================
public String jsonAction() {
// dataMap中的数据将会被Struts2转换成JSON字符串,所以这里要先清空其中的数据
jsonMap.clear();
jsonMap.put("success", true);
return JSON_TYPE;
}
//-------------------------华丽分割线---------------------------------------------//
//=============公=======共=======方=======法==========区=========start============//
/**
* 列表分页查询
*/
public String cj(){
Map<String,Object> alias = new HashMap<String,Object>();
StringBuffer sb = new StringBuffer();
sb = sb.append("from Cj where 1=1 and teacher.id="+UserUtils.getLoginId());
sb = sb.append(" order by id desc");
Pager<Cj> pagers = cjService.findByAlias(sb.toString(),alias);
ActionContext.getContext().put("pagers", pagers);
ActionContext.getContext().put("Obj", cj);
return SUCCESS;
}
public String cj2(){
Map<String,Object> alias = new HashMap<String,Object>();
StringBuffer sb = new StringBuffer();
sb = sb.append("from Cj where 1=1 and user.id="+UserUtils.getLoginId());
if(cj!=null && cj.getXk() !=null && !"".equals(cj.getXk().getName())){
sb.append(" and xk.nam like :realName ");
alias.put("realName", "%" +cj.getXk().getName()+ "%" );
}
sb = sb.append(" order by id desc");
Pager<Cj> pagers = cjService.findByAlias(sb.toString(),alias);
ActionContext.getContext().put("pagers", pagers);
ActionContext.getContext().put("Obj", cj);
return SUCCESS;
}
/**
* 跳转到添加页面
* @return
*/
public String add(){
List<Xk> listByAlias = xkService.listByAlias("from Xk where 1=1 and isDelete = 0", null);
ActionContext.getContext().put("xks", listByAlias);
return SUCCESS;
}
/**
* 执行添加
* @return
*/
public String exAdd(){
//
List<User> listByAlias = userService.listByAlias("from User where userName="+code, null);
if(!isEmpty(listByAlias)){
User user = listByAlias.get(0);
cj.setUser(user);
Teacher t = new Teacher();
t.setId(UserUtils.getLoginId());
cj.setTeacher(t);
cjService.save(cj);
jsonMap.put("res", 1);
}else{
jsonMap.put("res", 2);
}
return "json";
}
/**
* 查看详情页面
* @return
*/
public String view(){
Cj n = cjService.getById(cj.getId());
ActionContext.getContext().put("Obj", n);
return SUCCESS;
}
/**
* 跳转修改页面
* @return
*/
public String update(){
List<Xk> listByAlias = xkService.listByAlias("from Xk where 1=1 and isDelete = 0", null);
ActionContext.getContext().put("xks", listByAlias);
Cj n = cjService.getById(cj.getId());
ActionContext.getContext().put("Obj", n);
return SUCCESS;
}
/**
* 执行修改
* @return
*/
public String exUpdate(){
Cj n = cjService.getById(cj.getId());
n.setDf(cj.getDf());
n.setXk(cj.getXk());
cjService.update(n);
ActionContext.getContext().put("url", "/cj_cj.do");
return "redirect";
}
/**
* 删除
* @return
*/
public String delete(){
cjService.delete(cj.getId());
ActionContext.getContext().put("url", "/cj_cj.do");
return "redirect";
}
//=============公=======共=======方=======法==========区=========end============//
//-------------------------华丽分割线---------------------------------------------//
//=============自=======定=======义=========方=======法==========区=========start============//
//=============自=======定=======义=========方=======法==========区=========end============//
}
ClassRoomAction
package com.my.pro.action;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.my.pro.utils.Pager;
import com.opensymphony.xwork2.ModelDriven;
import java.util.*;
import com.my.pro.model.*;
import com.my.pro.dao.*;
import com.my.pro.service.*;
/**
* @ClassName:
* @Description:
* @author administrator
*
*/
@Controller("classRoomAction")
@Scope("prototype")
public class ClassRoomAction extends BaseAction implements ModelDriven<ClassRoom>{
private static final long serialVersionUID = 1L;
//==========model==============
private ClassRoom classRoom;
@Override
public ClassRoom getModel() {
if(classRoom==null) classRoom = new ClassRoom();
return classRoom;
}
//==========model==============
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private ClassRoomService classRoomService;
@Autowired
private ZyService zyService;
//依赖注入 end dao/service/===
//-------------------------华丽分割线---------------------------------------------
//============自定义参数start=============
//============自定义参数end=============
//-------------------------华丽分割线---------------------------------------------
//============文件上传start=======================================================
private File file;
//提交过来的file的名字
private String fileFileName;
//提交过来的file的MIME类型
private String fileContentType;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
//============文件上传end=========================================================
public String jsonAction() {
// dataMap中的数据将会被Struts2转换成JSON字符串,所以这里要先清空其中的数据
jsonMap.clear();
jsonMap.put("success", true);
return JSON_TYPE;
}
//-------------------------华丽分割线---------------------------------------------//
//=============公=======共=======方=======法==========区=========start============//
/**
* 列表分页查询
*/
public String classRoom(){
Map<String,Object> alias = new HashMap<String,Object>();
StringBuffer sb = new StringBuffer();
sb = sb.append("from ClassRoom where 1=1 and isDelete = 0 ");
if(classRoom!=null && classRoom.getName() !=null && !"".equals(classRoom.getName())){
sb.append(" and name like :realName ");
alias.put("realName", "%" +classRoom.getName()+ "%" );
}
sb = sb.append("order by id desc");
Pager<ClassRoom> pagers = classRoomService.findByAlias(sb.toString(),alias);
ActionContext.getContext().put("pagers", pagers);
ActionContext.getContext().put("Obj", classRoom);
return SUCCESS;
}
/**
* 跳转到添加页面
* @return
*/
public String add(){
List<Zy> listByAlias = zyService.listByAlias("from Zy where 1=1 and isDelete = 0 ", null);
ActionContext.getContext().put("zys", listByAlias);
return SUCCESS;
}
/**
* 执行添加
* @return
*/
public String exAdd(){
classRoom.setIsDelete(0);
classRoomService.save(classRoom);
ActionContext.getContext().put("url", "/classRoom_classRoom.do");
return "redirect";
}
/**
* 查看详情页面
* @return
*/
public String view(){
ClassRoom n = classRoomService.getById(classRoom.getId());
ActionContext.getContext().put("Obj", n);
return SUCCESS;
}
/**
* 跳转修改页面
* @return
*/
public String update(){
List<Zy> listByAlias = zyService.listByAlias("from Zy where 1=1 and isDelete = 0 ", null);
ActionContext.getContext().put("zys", listByAlias);
ClassRoom n = classRoomService.getById(classRoom.getId());
ActionContext.getContext().put("Obj", n);
return SUCCESS;
}
/**
* 执行修改
* @return
*/
public String exUpdate(){
ClassRoom n = classRoomService.getById(classRoom.getId());
n.setName(classRoom.getName());
n.setZy(classRoom.getZy());
classRoomService.update(n);
ActionContext.getContext().put("url", "/classRoom_classRoom.do");
return "redirect";
}
/**
* 删除
* @return
*/
public String delete(){
ClassRoom n = classRoomService.getById(classRoom.getId());
n.setIsDelete(1);
classRoomService.update(n);
ActionContext.getContext().put("url", "/classRoom_classRoom.do");
return "redirect";
}
//=============公=======共=======方=======法==========区=========end============//
//-------------------------华丽分割线---------------------------------------------//
//=============自=======定=======义=========方=======法==========区=========start============//
//=============自=======定=======义=========方=======法==========区=========end============//
}
如果也想学习本系统,下面领取。关注并回复:039ssh