作者主页:夜未央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版本;
6.是否Maven项目: 否;
技术栈
1. 后端:Spring Struts2 Hibernate
2. 前端:JSP+javascript+css+bootstrap+jQuery
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中config/jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入http://localhost:8080/登录
超级管理员账号/密码:super/super
管理员账号/密码:admin/admin
教师账号/密码: teacher/123456
运行截图

相关代码
CompetitionawardsAction
package com.my.scientific.action;
import com.my.scientific.utils.Contants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.http.HttpServletRequest;
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.scientific.utils.Pager;
import com.my.scientific.utils.UUIDUtils;
import com.my.scientific.utils.UserUtils;
import com.opensymphony.xwork2.ModelDriven;
import java.util.*;
import com.my.scientific.model.*;
import com.my.scientific.dao.*;
import com.my.scientific.service.*;
/**
* @ClassName:
* @Description:
* @author administrator
* @date 2015年12月24日 下午1:46:33 - 2016年11月26日 21时06分02秒
*/
@Controller("competitionAwardsAction")
@Scope("prototype")
public class CompetitionawardsAction extends ActionSupport implements ModelDriven<Competitionawards>{
private Integer my;
public Integer getMy() {
return my;
}
public void setMy(Integer my) {
this.my = my;
}
private static final long serialVersionUID = 1L;
//==========model==============
private Competitionawards competitionawards;
@Override
public Competitionawards getModel() {
if(competitionawards==null) competitionawards = new Competitionawards();
return competitionawards;
}
//==========model==============
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private CompetitionawardsService competitionawardsService;
//依赖注入 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=========================================================
//-------------------------华丽分割线---------------------------------------------//
//=============公=======共=======方=======法==========区=========start============//
/**
* 列表分页查询
*/
public String competitionAwards(){
Map<String,Object> alias = new HashMap<String,Object>();
StringBuffer sb = new StringBuffer();
sb = sb.append("from Competitionawards where 1=1 ");
if(my !=null && my == 1){
if(UserUtils.getLoginId() != null){
sb.append(" and user.id="+UserUtils.getLoginId());
}
}
ActionContext.getContext().put("my", my);
if(competitionawards!=null && competitionawards.getName() !=null && !"".equals(competitionawards.getName())){
sb.append(" and name like :name ");
alias.put("name", "%" +competitionawards.getName()+ "%");
}
sb = sb.append("order by id desc");
Pager<Competitionawards> pagers = competitionawardsService.findByAlias(sb.toString(),alias);
ActionContext.getContext().put("pagers", pagers);
ActionContext.getContext().put("CompetitionAwards", competitionawards);
return SUCCESS;
}
/**
* 跳转到添加页面
* @return
*/
public String add(){
return SUCCESS;
}
/**
* 执行添加
* @return
* @throws IOException
*/
public String exAdd() throws IOException{
competitionawards.setIsDelete(2);
competitionawards.setCreateTime(new Date());
ActionContext ac = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
String root = Contants.root;
if (file != null) {
InputStream is = new FileInputStream(file);
fileFileName = UUIDUtils.create() + fileFileName;
OutputStream os = new FileOutputStream(new File(root, fileFileName));
byte[] buffer = new byte[500];
int length = 0;
while (-1 != (length = is.read(buffer, 0, buffer.length))) {
os.write(buffer);
}
os.close();
is.close();
competitionawards.setWinFileUrl(root+fileFileName);
}
competitionawards.setUser( UserUtils.getUser());
competitionawardsService.save(competitionawards);
ActionContext.getContext().put("url", "/competitionAwards_competitionAwards.do");
return "redirect";
}
/**
* 查看详情页面
* @return
*/
public String view(){
Competitionawards n = competitionawardsService.getById(competitionawards.getId());
ActionContext.getContext().put("Competitionawards", n);
return SUCCESS;
}
/**
* 跳转修改页面
* @return
*/
public String update(){
Competitionawards n = competitionawardsService.getById(competitionawards.getId());
ActionContext.getContext().put("Competitionawards", n);
return SUCCESS;
}
/**
* 执行修改
* @return
* @throws Exception
*/
public String exUpdate() throws Exception{
// private int id;
//
// private String type;//奖项类别
//
// private String name;//名称
//
// private String awardName;//得奖人名称
//
// private String mechanism;//颁奖机构
//
// private String zhengshu;//证书
//
// private Date winningTime;//获奖时间
//
// private String winFileName;//文件名
//
// private String winFileUrl;//文件路径
//
// private User user;//
//
// private Date createTime;//创建时间
Competitionawards n = competitionawardsService.getById(competitionawards.getId());
competitionawards.setIsDelete(2);
ActionContext ac = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
String root = Contants.root;
if (file != null) {
InputStream is = new FileInputStream(file);
fileFileName = UUIDUtils.create() + fileFileName;
OutputStream os = new FileOutputStream(new File(root, fileFileName));
byte[] buffer = new byte[500];
int length = 0;
while (-1 != (length = is.read(buffer, 0, buffer.length))) {
os.write(buffer);
}
os.close();
is.close();
competitionawards.setWinFileUrl(root+fileFileName);
}
n.setType(competitionawards.getType());
n.setName(competitionawards.getName());
n.setAwardName(competitionawards.getAwardName());
n.setMechanism(competitionawards.getMechanism());
n.setZhengshu(competitionawards.getZhengshu());
n.setWinningTime(competitionawards.getWinningTime());
n.setWinFileUrl(competitionawards.getWinFileUrl());
competitionawardsService.update(n);
ActionContext.getContext().put("url", "/competitionAwards_competitionAwards.do");
return "redirect";
}
/**
* 删除
* @return
*/
public String delete(){
competitionawardsService.delete(competitionawards.getId());
ActionContext.getContext().put("url", "/competitionAwards_competitionAwards.do");
return "redirect";
}
//=============公=======共=======方=======法==========区=========end============//
//-------------------------华丽分割线---------------------------------------------//
//=============自=======定=======义=========方=======法==========区=========start============//
//=============自=======定=======义=========方=======法==========区=========end============//
}
LoginAction
package com.my.scientific.action;
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.my.scientific.model.Manage;
import com.my.scientific.model.User;
import com.my.scientific.service.ManageService;
import com.my.scientific.service.UserService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
@Controller("loginAction")
@Scope("prototype")
public class LoginAction extends ActionSupport {
//============依赖注入start================
@Autowired
private ManageService manageService;//管理
@Autowired
private UserService userService;//用户
//===========依赖注入end==================
//-------------------------华丽分割线---------------------------------------------
//============自定义参数start=============
private String userName;
private String passWord;
private int role;
private Integer keyword1;
private Integer keyword2;
public Integer getKeyword1() {
return keyword1;
}
public void setKeyword1(Integer keyword1) {
this.keyword1 = keyword1;
}
public Integer getKeyword2() {
return keyword2;
}
public void setKeyword2(Integer keyword2) {
this.keyword2 = keyword2;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassWord() {
return passWord;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
public int getRole() {
return role;
}
public void setRole(int role) {
this.role = role;
}
//============自定义参数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 login() {
return "manageLogin";
}
//注册页面(只有前台有注册)
public String register() {
return "userRegister";
}
//登录
public String toLogin(){
// <option value="1">超级管理员</option>
// <option value="2">管理员</option>
// <option value="3">教师</option>
if(role==3){
String hql = "from User where userName = :userName and passWord = :passWord and isDelete=2";
Map<String,Object> alias = new HashMap<String,Object>();
alias.put("userName",userName);
alias.put("passWord", passWord);
List<User> userList= userService.getByHQL(hql, alias);
if(userList.size()>0){
//将用户信息放入session
HttpSession session = ServletActionContext.getRequest()
.getSession();
session.setAttribute("userName", userList.get(0).getRealName());
session.setAttribute("userId",userList.get(0).getId() );
session.setAttribute("user", userList.get(0));
session.setAttribute("roleId", role);
return "manageIndex";
}else{
return "manageLogin";
}
}else{
String hql = "from Manage where name = :userName and passWord = :passWord and type="+role;
Map<String,Object> alias = new HashMap<String,Object>();
alias.put("userName",userName);
alias.put("passWord", passWord);
List<Manage> manageList=manageService.getByHQL(hql, alias);
if(manageList.size()>0){
//将用户信息放入session
HttpSession session = ServletActionContext.getRequest()
.getSession();
session.setAttribute("userName", manageList.get(0).getRealName());
session.setAttribute("userId2",manageList.get(0).getId() );
session.setAttribute("manage", manageList.get(0));
session.setAttribute("roleId", role);
return "manageIndex";
}else{
return "manageLogin";
}
}
}
//退出
public String tuichu() {
ActionContext ac = ActionContext.getContext();
Map session = ac.getSession();
session.remove("userName");
session.remove("userId");
if(role==1){
return "userLogin";
}else{
return "manageLogin";
}
}
}
如果也想学习本系统,下面领取。关注并回复:117ssh