基于javaweb+mysql的jsp+servlet毕业设计管理系统(java+jsp+javascript+servlet+mysql)

基于javaweb+mysql的jsp+servlet毕业设计管理系统(java+jsp+javascript+servlet+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb+mysql的JSP+Servlet毕业设计管理系统(java+jsp+javascript+servlet+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.数据库:MySql 5.7版本; 6.是否Maven项目:否;

技术栈 JSP+CSS+JavaScript+servlet+mysql

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中Connector.java配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080/jsp_bysjsys/ 登录 学生账号/密码: student/123456 指导教师账号/密码: teacher/123456 管理员账号/密码:admin/admin

    public void modifypwd(String username,String newpwd) throws SQLException {
        Connection conn = null;
        PreparedStatement ps = null;
        
        try {
            conn = this.connector.getConnection();
            conn.setAutoCommit(false);

            ps = conn.prepareStatement(UPDATE_USER_PASSWORD);
            ps.setString(1, newpwd);
            ps.setString(2, username);
            
            if (ps.executeUpdate() != 1) {
                conn.rollback();
                System.out.println("--修改用户密码失败。");
            } else {
                System.out.println("--修改用户密码成功。");

                conn.commit();
                conn.setAutoCommit(true);
            }

        } catch (SQLException e) {
            throw new SQLException(e);
        } finally {
            connector.closePreparedStatement(ps);
            connector.closeConnection(conn);
        }
    }

    public void modifyContact(String username, String email, String telphone) throws SQLException {
        Connection conn = null;
        PreparedStatement ps = null;
        
        try {
            conn = this.connector.getConnection();
            conn.setAutoCommit(false);

            ps = conn.prepareStatement(UPDATE_USER_CONTACT);
            ps.setString(1, email);
            ps.setString(2, telphone);
            ps.setString(3, username);
            
            if (ps.executeUpdate() != 1) {
                conn.rollback();
                System.out.println("--修改用户联系方式失败。");
            } else {
                System.out.println("--修改用户联系方式成功。");

                conn.commit();
                conn.setAutoCommit(true);
            }

        
        try {
            conn = this.connector.getConnection();
            conn.setAutoCommit(false);
            
            ps = conn.prepareStatement(INSERT_NOTICE);
            
            ps.setString(1, notice.getNtitle());
            ps.setString(2, notice.getScope());
            ps.setString(3, notice.getNcontent());
            
            if (ps.execute()) {
                conn.rollback();
                System.out.println("--更新通知信息失败。");
            } else {
                System.out.println("--更新通知信息成功。");

                conn.commit();
                conn.setAutoCommit(true);
            }

        } catch (SQLException e) {
            throw new Exception(e);
        } finally {
            connector.closePreparedStatement(ps);
            connector.closeConnection(conn);
        }
    }

    /**
     * 分页显示通知列表
     * @param i 从第几项开始
     * @param j 每页的行数
     * @param scope 通知的范围(校级,院级)
     * @return
     * @throws SQLException 
     */
    public List<Notice> getNoticeList(int i, int j, String scope) throws SQLException {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;

        List<Notice> noticeList = new ArrayList<Notice>();
        
        try {
                        </fieldset>

                    </form>

                
                </section>
                <!-- End of Left column/section -->
                     
            <!-- Right column/section -->
            <aside class="column width2">
                <jsp:include page="aside.jsp"></jsp:include>
            </aside>
            <!-- End of Right column/section -->
                
        </div>
        <!-- End of Wrapper -->
    </div>
    <!-- End of Page content -->
    
    <jsp:include page="footer.jsp"></jsp:include>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>

<jsp:include page="header.jsp"></jsp:include>

<script type="text/javascript">
$(document).ready(function(){
    
    /* setup navigation, content boxes, etc... */
    Administry.setup();

});

/* 修改密码,ajax */
function modifypwd(){
    var newpwd = $("#newpwd").val();

public class InspectionDAO {

    private static final String INSERT_NEW_INSPECTION = "insert into inspection(taskid,progress,problem,subtime) values(?,?,?,now())";
    private static final String GET_INSPECTION_BY_TASKID = "select * from inspection where taskid=?";
    
    private Connector connector;
    
    public InspectionDAO() {
        this.connector = new Connector();
    }
    
    
    public void insertInspection(String taskid, String progress, String problem) throws SQLException {
        Connection conn = null;
        PreparedStatement ps = null;
        
        try {
            conn = this.connector.getConnection();
            conn.setAutoCommit(false);

            ps = conn.prepareStatement(INSERT_NEW_INSPECTION);
            ps.setString(1, taskid);
            ps.setString(2, progress);
            ps.setString(3, problem);
            
            if (ps.execute()) {
                conn.rollback();
                System.out.println("--插入中期检查失败。");
            } else {
                System.out.println("--插入中期检查成功。");

                conn.commit();
                conn.setAutoCommit(true);
            }

        } catch (SQLException e) {
            throw new SQLException(e);
        } finally {
            connector.closePreparedStatement(ps);
            connector.closeConnection(conn);
            connector.closeConnection(conn);
        }
    }

    public void modifyContact(String username, String email, String telphone) throws SQLException {
        Connection conn = null;
        PreparedStatement ps = null;
        
        try {
            conn = this.connector.getConnection();
            conn.setAutoCommit(false);

            ps = conn.prepareStatement(UPDATE_USER_CONTACT);
            ps.setString(1, email);
            ps.setString(2, telphone);
            ps.setString(3, username);
            
            if (ps.executeUpdate() != 1) {
                conn.rollback();
                System.out.println("--修改用户联系方式失败。");
            } else {
                System.out.println("--修改用户联系方式成功。");

                conn.commit();
                conn.setAutoCommit(true);
            }

        } catch (SQLException e) {
            throw new SQLException(e);
        } finally {
            connector.closePreparedStatement(ps);
            connector.closeConnection(conn);
        }
        
    }

    public List<User> getTeacherList(String collegeid) throws SQLException {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        

        return sb;
    }

    public String getNameById(String classid) throws SQLException {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        
        try {
            conn = this.connector.getConnection();
            ps = conn.prepareStatement(GET_CLASS_NAME_BY_ID);
            ps.setString(1, classid);

            rs = ps.executeQuery();

            if (rs.next()) {
                System.out.println("--获取班级名成功");
                return rs.getString("cname");
            } else {
                System.out.println("--获取班级名失败");
                return "";
            }

        } catch (SQLException e){
            throw new SQLException(e);
        } finally {
            this.connector.closeResultSet(rs);
            this.connector.closePreparedStatement(ps);
            this.connector.closeConnection(conn);
        }
    }

    public boolean isExist(String classid) {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        
        try {
            conn = this.connector.getConnection();
            ps = conn.prepareStatement(CLASS_IS_EXIST);
            ps.setString(1, classid);


public class NoticeAction {
    
    private String message;
    
    private Notice notice;
    private String ntitle;
    private String ncontent;
    
    private int id;  //查看通知是所使用的ID
    private String scope; //查看校级(院级)通知列表时使用的参数
    private List<Notice> notices = null;  //首页通知列表
    
    public String submitNotice(){
        
        User user = BaseUnit.getLoginUser();
        if("sysadmin".equalsIgnoreCase(user.getRole())){
            notice = new Notice(ntitle, "all", ncontent);
        } else {
            notice = new Notice(ntitle, user.getCollegeid(), ncontent);
        }
        
        NoticeDAO noticeDao = new NoticeDAO();
        try {
            noticeDao.insert(notice);
        } catch (Exception e) {
            e.printStackTrace();
            message = "发布通知失败";
            return "notexist";
        }
        
        message = "发布通知成功";
        return "success";
    }
    
    public String viewNotice(){
        NoticeDAO noticeDao = new NoticeDAO();
        try {
            notice = noticeDao.getNoticeById(id);
            return "success";
        } catch (SQLException e) {
            e.printStackTrace();
            message = "查看通知内容失败。";
            return "notexist";
        }
    }
    
    public String moreNotice(){
        return taskid;
    }

    public void setTaskid(String taskid) {
        this.taskid = taskid;
    }

    public Task getTask() {
        return task;
    }

    public void setTask(Task task) {
        this.task = task;
    }
    
    public Inspection getInspect() {
        return inspect;
    }

    public void setInspect(Inspection inspect) {
        this.inspect = inspect;
    }

    public String getProgress() {
        return progress;
    }

    public void setProgress(String progress) {
        this.progress = progress;
    }

    public String getProblem() {
        return problem;
    }

    public void setProblem(String problem) {
        this.problem = problem;
    }
    
}
            </div>
            <!-- End of Top navigation -->
            <!-- Main navigation -->
            <nav id="menu">
                <ul class="sf-menu">
                    <li><a HREF="main.jsp">首页</a></li>
                    <s:if test='#session.loginUser.role=="sysadmin"'>
                        <li><a HREF="college">管理学院</a></li>
                        <li><a HREF="dept">管理专业</a></li>
                        <li><a HREF="class">管理班级</a></li> 
                        <li class="current"><a HREF="adduser">注册用户</a></li>
                        <li><a HREF="notice.jsp">发布校级通知</a></li>
                    </s:if>
                    <s:elseif test='#session.loginUser.role=="student"'>
                        <li><a HREF="userinfo">个人信息</a></li>
                        <li><a HREF="subtask">选题信息</a></li>
                        <li><a HREF="viewreport">开题报告</a></li> 
                        <li><a HREF="viewinspect">中期检查</a></li>
                        <li><a HREF="mypaper">论文</a></li>
                        <li><a HREF="message">消息</a></li> 
                        </s:elseif>
                    <s:elseif test='#session.loginUser.role=="teacher"'>
                        <li><a HREF="userinfo">个人信息</a></li>
                        <li><a HREF="approval">待我审批</a></li>
                        <li><a HREF="tasksoftea">课题状态</a></li> 
                        <li><a HREF="message">消息</a></li>  
                    </s:elseif>
                    <s:elseif test='#session.loginUser.role=="deptadmin"'>
                        <li><a HREF="userinfo">个人信息</a></li>
                        <li><a HREF="approval">待我审批</a></li>
                        <li><a HREF="notice.jsp">发布院级通知</a></li>
                    </s:elseif>
                </ul>
            </nav>
            <!-- End of Main navigation -->
            <!-- Aside links -->
            <aside>
                <b>欢迎您:</b> 
                <a href="#">
                    <s:if test="#session.loginUser.realname==null">
                        <s:property value="#session.loginUser.username" />
                    </s:if>
    public Notice getNoticeById(int id) throws SQLException {
        
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        Notice notice = null;
        
        try {
            conn = this.connector.getConnection();
            ps = conn.prepareStatement(GET_NOTICE_BY_ID);
            ps.setInt(1, id);

            rs = ps.executeQuery();

            if (rs.next()) {
                notice = new Notice(rs.getInt("noticeid"), rs.getString("ntitle"), 
                                    rs.getString("scope"), rs.getString("ncontent"), 
                                    rs.getDate("time").toString() + " " + rs.getTime("time").toString());
                System.out.println("--获取通知全文信息。");
                
            } else {
                System.out.println("--获取通知全文信息失败。");
                return notice;
            }

        } catch (SQLException e){
            throw new SQLException(e);
        } finally {
            this.connector.closeResultSet(rs);
            this.connector.closePreparedStatement(ps);
            this.connector.closeConnection(conn);
        }
        return notice;
        
    }
        
}

/**
 *
 */
                conn.commit();
                conn.setAutoCommit(true);
            }

        } catch (SQLException e) {
            throw new SQLException(e);
        } finally {
            connector.closePreparedStatement(ps);
            connector.closeConnection(conn);
        }
        
        
    }

    public boolean isExist(String username) {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        
        try {
            conn = this.connector.getConnection();
            ps = conn.prepareStatement(USER_IS_EXIST);
            ps.setString(1, username);

            rs = ps.executeQuery();

            rs.next();
            if (rs.getInt(1) == 1) {
                System.out.println("此用户帐号已存在");
                return true;
            } else {
                return false;
            }

        } catch (SQLException e){
            e.printStackTrace();
        } finally {
            this.connector.closeResultSet(rs);
            this.connector.closePreparedStatement(ps);
            this.connector.closeConnection(conn);
        }
        
        return false;
    }

    public void modifypwd(String username,String newpwd) throws SQLException {
        Connection conn = null;
        PreparedStatement ps = null;
        
        try {
            conn = this.connector.getConnection();
            conn.setAutoCommit(false);
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getCollegeName() {
        return collegeName;
    }

    public void setCollegeName(String collegeName) {
        this.collegeName = collegeName;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
    
}

        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getTaskid() {
        return taskid;
    }

    public void setTaskid(String taskid) {
        this.taskid = taskid;
    }

    public Task getTask() {
        return task;
    }

    public void setTask(Task task) {
        this.task = task;
    }
    
    public Inspection getInspect() {
        return inspect;
    }

    public void setInspect(Inspection inspect) {
        this.inspect = inspect;
    }

    public String getProgress() {
        return progress;
    }

    public void setProgress(String progress) {
        this.progress = progress;
    }

    public String getProblem() {
        return problem;
    }

    public void setProblem(String problem) {
        this.problem = problem;
    }
    
}

        } catch (SQLException e) {
            throw new SQLException(e);
        } finally {
            connector.closePreparedStatement(ps);
            connector.closeConnection(conn);
        }  
        
    }

}

public class RegisterAction {
    
    private List<College> colleges = new ArrayList<College>();
    private String message;
    
    private String username;
    private String role;
    private String realname;
    
    private String collegeid;
    private String deptid;
    private String classid;
    
    
    public String getAllColleges(){
            ps.setString(1, taskid);
            ps.setString(2, progress);
            ps.setString(3, problem);
            
            if (ps.execute()) {
                conn.rollback();
                System.out.println("--插入中期检查失败。");
            } else {
                System.out.println("--插入中期检查成功。");

                conn.commit();
                conn.setAutoCommit(true);
            }

        } catch (SQLException e) {
            throw new SQLException(e);
        } finally {
            connector.closePreparedStatement(ps);
            connector.closeConnection(conn);
        }  
        
    }

    public Inspection getInspectByTaskid(String taskid) throws SQLException {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        Inspection inspect = null;
        
        try {
            conn = this.connector.getConnection();
            ps = conn.prepareStatement(GET_INSPECTION_BY_TASKID);
            ps.setString(1, taskid);

            rs = ps.executeQuery();
            if (rs.next()) {
                inspect = new Inspection();
                inspect.setInspectionid(rs.getString("inspectionid"));
                inspect.setTaskid(rs.getString("taskid"));
                inspect.setProgress(rs.getString("progress"));
                inspect.setProblem(rs.getString("problem"));
                inspect.setTeaopinion(rs.getString("teaopinion"));
                inspect.setDeptopinion(rs.getString("deptopinion"));
                inspect.setSubtime(rs.getDate("subtime").toString() + " " + rs.getTime("subtime").toString());
                
                System.out.println("--获取中期检查信息。");
                
            } else {
                return inspect;
        NoticeDAO noticeDao = new NoticeDAO();
        try {
            noticeDao.insert(notice);
        } catch (Exception e) {
            e.printStackTrace();
            message = "发布通知失败";
            return "notexist";
        }
        
        message = "发布通知成功";
        return "success";
    }
    
    public String viewNotice(){
        NoticeDAO noticeDao = new NoticeDAO();
        try {
            notice = noticeDao.getNoticeById(id);
            return "success";
        } catch (SQLException e) {
            e.printStackTrace();
            message = "查看通知内容失败。";
            return "notexist";
        }
    }
    
    public String moreNotice(){
        NoticeDAO noticeDao = new NoticeDAO();
        try {
            notices = noticeDao.getNoticeList(0,100,scope);
        } catch (SQLException e) {
            e.printStackTrace();
            message = "系统错误";
            return "notexist";
        }
        
        return "success";
    }
    
    public String notexist(){
        return "notexist";
    }
    
    public Notice getNotice() {
        return notice;
    }
    public String register(){
        HttpServletResponse response = ServletActionContext.getResponse();
        UserDAO userDao = new UserDAO();
        User user = new User();
        
        String str = "";

        if ("".equals(username)) {
            str = "用户帐号不能为空";
        } else if ("".equals(realname)) {
            str = "真实姓名不能为空";
        } else if ("0".equals(collegeid)) {
            str = "请选择所在学院";
        } else if (userDao.isExist(username)){
            str = "此帐号已存在";
        } else {
            user.setUsername(username);
            user.setPassword(username);
            user.setRole(role);
            user.setRealname(realname);
            user.setCollegeid(collegeid);
            user.setDeptid(deptid);
            user.setClassid(classid);
            
            try {
                userDao.register(user);
            } catch (SQLException e) {
                e.printStackTrace();
                message = "系统错误";
                return "notexist";
            }
            str = "成功注册新用户!";
        }
        
        
        try {           
            response.setCharacterEncoding("utf-8");
            response.getWriter().write(str);
        } catch (IOException e) {
            e.printStackTrace();
            message = "系统错误";
            return "notexist";
        }
        
        return null;
    }
    
    public String notexist(){
    public static final String GET_OUTBOX_MESSAGELIST = "select * from message where fromid=?";
    public static final String GET_MESSAGE_BY_ID = "select * from message where messageid=?";
    public static final String DELETE_MESSAGE_BY_ID = "delete from message where messageid=?";
    
    private Connector connector;
    
    public MessageDAO() {
        this.connector = new Connector();
    }

    public void insertMess(String fromid, String toid, String messtitle,
            String messcontent) throws SQLException {
        Connection conn = null;
        PreparedStatement ps = null;
        
        try {
            conn = this.connector.getConnection();
            conn.setAutoCommit(false);

            ps = conn.prepareStatement(INSERT_NEW_MESSAGE_WITHOUT_ATTACHMENT);
            ps.setString(1, fromid);
            ps.setString(2, toid);
            ps.setString(3, messtitle);
            ps.setString(4, messcontent);
            
            if (ps.execute()) {
                conn.rollback();
                System.out.println("--插入消息失败。");
            } else {
                System.out.println("--插入消息成功。");

                conn.commit();
                conn.setAutoCommit(true);
            }

        } catch (SQLException e) {
            throw new SQLException(e);
        } finally {
            connector.closePreparedStatement(ps);
            connector.closeConnection(conn);
        }        

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值