1. 程式人生 > >學生成績管理系統(SSM+MySQL+JSP)

學生成績管理系統(SSM+MySQL+JSP)

開發工具:Eclipse
前端技術:
基礎:html+css+JavaScript
框架:JQuery+H-ui
後端技術:Spring+SpringMVC+mybatis
模板引擎:JSP
資料庫:mysql 5.7.27
jdk版本:1.8.0_251
tomcat版本:Tomcat 9.0
資料庫連線池:druid

一、功能概述

學生管理系統的使用者包括學生、教師及管理員。
(1)學生可以對個人的各科成績進行查詢、個人資訊修改、選課、修改登入密碼等操作。
(2)教師可以對學生資訊、教師個人資訊、課程資訊、成績等進行管理,實現對這些資訊的查詢、錄入、新增、修改、刪除等操作。
(3)管理員可以對學生、教師、課程、成績資訊進行管理,實現對這些資訊的查詢、錄入、新增、修改、刪除以及許可權管理等操作。

功能結構圖:

二、資料庫表結構

成績表(Score):

學生表(student):

課程表(subject):

教師表(teacher):

使用者表(user):

三、專案結構

四、配置SSM檔案

Spring-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc"  
    xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd"
    default-lazy-init="true">

    <description>Spring Configuration</description>
    
    <!-- 載入配置屬性檔案 -->
    <context:property-placeholder ignore-unresolvable="true" location="classpath:demo.properties" />
    
    <!-- 使用Annotation自動註冊Bean,解決事物失效問題:在主容器中不掃描@Controller註解,在SpringMvc中只掃描@Controller註解。  -->
    <context:component-scan base-package="com.stusystem.controller"><!-- base-package 如果多個,用“,”分隔 -->
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>
    
     <!-- MyBatis begin -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="typeAliasesPackage" value="com.stusystem.entity"/>
        <property name="mapperLocations" value="classpath:/com/stusystem/mappings/**/*.xml"/>
        <property name="configLocation" value="classpath:/mybatis-config.xml"></property>
    </bean>
    
    <!-- 掃描basePackage下所有以@MyBatisDao註解的介面 -->
    <bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
        <property name="basePackage" value="com.stusystem.dao"/>
    </bean>
    
    <!-- 定義事務,用@Transactiona註解表示事物 -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>
    
    <!-- 配置 Annotation 驅動,掃描@Transactional註解的類定義事務  -->
    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
    <!-- MyBatis end -->
    
    <!-- 配置 JSR303 Bean Validator 定義 -->
    <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
    
    <!-- 資料來源配置, 使用 BoneCP 資料庫連線池 -->
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> 
        <!-- 資料來源驅動類可不寫,Druid預設會自動根據URL識別DriverClass -->
        <property name="driverClassName" value="${jdbc.driver}" />
        
        <!-- 基本屬性 url、user、password -->
        <property name="url" value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
        
        <!-- 配置初始化大小、最小、最大 -->
        <property name="initialSize" value="${jdbc.pool.init}" />
        <property name="minIdle" value="${jdbc.pool.minIdle}" /> 
        <property name="maxActive" value="${jdbc.pool.maxActive}" />
        
        <!-- 配置獲取連線等待超時的時間 -->
        <property name="maxWait" value="60000" />
        
        <!-- 配置間隔多久才進行一次檢測,檢測需要關閉的空閒連線,單位是毫秒 -->
        <property name="timeBetweenEvictionRunsMillis" value="60000" />
        
        <!-- 配置一個連線在池中最小生存的時間,單位是毫秒 -->
        <property name="minEvictableIdleTimeMillis" value="300000" />
        
        <property name="validationQuery" value="${jdbc.testSql}" />
        <property name="testWhileIdle" value="true" />
        <property name="testOnBorrow" value="false" />
        <property name="testOnReturn" value="false" />
        
        <!-- 配置監控統計攔截的filters -->
        <property name="filters" value="stat" /> 
    </bean>
    
</beans>

 

Mybatis-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>

    <!-- 全域性引數 -->
    <settings>
        <!-- 使全域性的對映器啟用或禁用快取。 -->
        <setting name="cacheEnabled" value="true"/>
        
        <!-- 全域性啟用或禁用延遲載入。當禁用時,所有關聯物件都會即時載入。 -->
        <setting name="lazyLoadingEnabled" value="true"/>
        
        <!-- 當啟用時,有延遲載入屬性的物件在被呼叫時將會完全載入任意屬性。否則,每種屬性將會按需要載入。 -->
        <setting name="aggressiveLazyLoading" value="true"/>
        
        <!-- 是否允許單條sql 返回多個數據集  (取決於驅動的相容性) default:true -->
        <setting name="multipleResultSetsEnabled" value="true"/>
        
        <!-- 是否可以使用列的別名 (取決於驅動的相容性) default:true -->
        <setting name="useColumnLabel" value="true"/>
        
        <!-- 允許JDBC 生成主鍵。需要驅動器支援。如果設為了true,這個設定將強制使用被生成的主鍵,有一些驅動器不相容不過仍然可以執行。  default:false  -->
        <setting name="useGeneratedKeys" value="false"/>
        
        <!-- 指定 MyBatis 如何自動對映 資料基表的列 NONE:不隱射 PARTIAL:部分  FULL:全部  -->  
        <setting name="autoMappingBehavior" value="PARTIAL"/>
        
        <!-- 這是預設的執行型別  (SIMPLE: 簡單; REUSE: 執行器可能重複使用prepared statements語句;BATCH: 執行器可以重複執行語句和批量更新)  -->
        <setting name="defaultExecutorType" value="SIMPLE"/>
        
        <!-- 使用駝峰命名法轉換欄位。 -->
        <setting name="mapUnderscoreToCamelCase" value="true"/>
        
        <!-- 設定本地快取範圍 session:就會有資料的共享  statement:語句範圍 (這樣就不會有資料的共享 ) defalut:session -->
        <setting name="localCacheScope" value="SESSION"/>
        
        <!-- 設定但JDBC型別為空時,某些驅動程式 要指定值,default:OTHER,插入空值時不需要指定型別 -->
        <setting name="jdbcTypeForNull" value="NULL"/>
        
    </settings>
    
</configuration>
spring-mvc.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
    
    <description>Spring MVC Configuration</description>
    
    <!-- 載入配置屬性檔案 -->
    <context:property-placeholder ignore-unresolvable="true" location="classpath:demo.properties" />
    
    <!-- 使用Annotation自動註冊Bean,只掃描@Controller -->
    <context:component-scan base-package="com.stusystem" use-default-filters="false"><!-- base-package 如果多個,用“,”分隔 -->
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>
    
    <!-- 預設的註解對映的支援,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping -->
    <mvc:annotation-driven content-negotiation-manager="contentNegotiationManager">
        <mvc:message-converters register-defaults="true">
            <!-- 將StringHttpMessageConverter的預設編碼設為UTF-8 -->
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <constructor-arg value="UTF-8" />
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>
    
    <!-- REST中根據URL字尾自動判定Content-Type及相應的View -->
    <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
        <property name="mediaTypes" >
            <map> 
                <entry key="xml" value="application/xml"/> 
                <entry key="json" value="application/json"/> 
            </map>
        </property>
        <property name="ignoreAcceptHeader" value="true"/>
        <property name="favorPathExtension" value="true"/>
    </bean>
    
    <!-- 定義檢視檔案解析 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/"/>
        <!--  <property name="suffix" value="${web.view.suffix}"/> -->
        <property name="suffix" value=".jsp"/>
    </bean>
    
    <!-- 對靜態資原始檔的訪問, 將無法mapping到Controller的path交給default servlet handler處理 -->
    <mvc:default-servlet-handler />
    
    <!-- 靜態資源對映 -->
    <mvc:resources mapping="/static/**" location="/static/" cache-period="31536000"/>
    
    <!-- 定義無Controller的path<->view直接對映 -->
    <mvc:view-controller path="/" view-name="redirect:${web.view.index}"/>
    
        <mvc:interceptors>
            <!--多個攔截器,順序執行 -->
            <!-- 登陸認證攔截器 -->
            <mvc:interceptor>
                <mvc:mapping path="/**"/>
                <bean class="com.stusystem.interceptor.LoginInterceptor"></bean>
            </mvc:interceptor>
        </mvc:interceptors>
</beans>

五、配置web.xml和demo.properties

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>stusystem_3</display-name>
    
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:/spring-context*.xml</param-value>
    </context-param>
    
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <servlet>
        <servlet-name>springServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:/spring-mvc*.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>springServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>DruidStatView</servlet-name>
        <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
        <init-param>
            <param-name>allow</param-name>
            <param-value>127.0.0.1</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>DruidStatView</servlet-name>
        <url-pattern>/druid/*</url-pattern>
    </servlet-mapping>

    <session-config>
        <session-timeout>600</session-timeout>
    </session-config>
    
    
    <servlet-mapping>  
        <servlet-name>default</servlet-name>  
            <url-pattern>/js/*</url-pattern>  
            <url-pattern>/css/*</url-pattern>  
            <url-pattern>/images/*</url-pattern>  
            <url-pattern>/font/*</url-pattern>  
            <url-pattern>/assets/*</url-pattern>  
            <url-pattern>/lib/*</url-pattern>  
    </servlet-mapping> 
    
</web-app>

demo.properties

#============================#
#===== Database settings ====#
#============================#

#mysql database setting
jdbc.type=mysql
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/stusystem?useUnicode=true&characterEncoding=utf-8
jdbc.username=root
jdbc.password=123456

#pool settings
jdbc.pool.init=1
jdbc.pool.minIdle=3
jdbc.pool.maxActive=20

#jdbc.testSql=SELECT 'x'
jdbc.testSql=SELECT 'x' FROM DUAL


web.view.prefix=/
web.view.suffix=.jsp


web.view.index=/StuSystem/user/login

六、各個模組程式碼

UserBean.java:

package com.stusystem.entity;
import org.apache.ibatis.type.Alias;
import org.springframework.stereotype.Component;
@Alias("userbean")
@Component
public class Userbean {
    private String userName;
    private int userId;
    private String admin;
    private String password;
    private String xmm;
    public String getXmm() {
        return xmm;
    }
    public void setXmm(String xmm) {
        this.xmm = xmm;
    }
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public int getUserId() {
        return userId;
    }
    public void setUserId(int userId) {
        this.userId = userId;
    }
    public String getAdmin() {
        return admin;
    }
    public void setAdmin(String admin) {
        this.admin = admin;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
}
UserDao.java:

package com.stusystem.dao;

import com.stusystem.entity.Userbean;


public interface  UserDao {
    //驗證登入資訊
    public Userbean getUsrInfoByNameAndPsw(Userbean userbean);
    //修改密碼
    public void mmxg(Userbean userbean);
}
UserDao.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 

<!-- namesapce ,DAO的package路徑  -->
<mapper namespace="com.stusystem.dao.UserDao">
    <!-- 根據使用者輸入的使用者名稱和密碼查詢是否存在此使用者  -->
    <select id="getUsrInfoByNameAndPsw" parameterType="userbean" resultType="userbean">
        select * from user where user_id=#{userId} and password=#{password} and admin=#{admin}
    </select>
    <!-- 修改登入使用者的密碼  -->
    <update id="mmxg" parameterType="userbean">
        UPDATE user SET password = #{xmm} WHERE (user_id=#{userId})
    </update>
</mapper>
UserController.java:

package com.stusystem.controller;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.stusystem.dao.UserDao;
import com.stusystem.entity.Userbean;
@Controller
@RequestMapping(value = "user")
public class UserController {
    @Autowired
    private UserDao userDao;
//    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:spring-context.xml");
//    UserDao userDao = (UserDao) applicationContext.getBean("userDao");
    //返回登陸介面
    //驗證使用者的使用者名稱和密碼是有和資料庫中的匹配
    @RequestMapping(value = {"/login"})
    public String userlogin() {
        return "login";
    }
    //登陸驗證
    @RequestMapping(value = {"/loginyanzheng"})
    public void loginyanzheng(Userbean userbean,HttpServletResponse response,HttpServletRequest request) throws IOException {
        Userbean user = userDao.getUsrInfoByNameAndPsw(userbean);
        if(user==null){
            response.getWriter().println("{\"status\":0,\"msg\":\"使用者名稱或密碼有誤!\"}");
        }else{
            // 使用者的資訊存放到session中。
            HttpSession session = request.getSession();
            session.setAttribute("userbean", user);
            response.getWriter().println("{\"status\":1,\"url\":\"index\"}");
        }
    }
    //返回系統主介面
    @RequestMapping(value = {"/index"})
    public String index() {
        return "index";
    }
    //返回關於頁面
    @RequestMapping(value = {"/gy"})
    public String guanyu() {
        return "gy";
    }
    //返回密碼修改頁面
    @RequestMapping(value = {"/dlmmxg"})
    public String dlmmxg() {
        return "dlmmxg";
    }
    //修改登入密碼
    @RequestMapping(value = {"/mmxg"})
    public String mmxg(Userbean userbean,HttpServletResponse response,HttpServletRequest request){
        Userbean user = userDao.getUsrInfoByNameAndPsw(userbean);
        if(user==null){
            request.setAttribute("status", '0');
        }else{
            userDao.mmxg(userbean);
            request.setAttribute("status", '1');
        }
        return "dlmmxg";
    }
    //退出系統
    @RequestMapping(value = {"/loginout"})
    public String loginout(HttpServletRequest request){
        HttpSession session = request.getSession();
        session.invalidate();
        return "login";
    }
}
login.jsp

<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<html>
<head>
    <meta http-equiv="content-type" content="text/html">
    <meta charset="UTF-8">
    <title>學生成績管理系統|登入</title>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/host.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/animate.min.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrap.min.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/font-awesome.min.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/style.min.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/iconfont.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/js/validator-0.7.3/jquery.validator.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/sweetalert/sweetalert.css">
    <script src="<%=request.getContextPath()%>/js/jquery-1.8.3.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/validator-0.7.3/jquery.validator.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/validator-0.7.3/local/zh_CN.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/host.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/sweetalert/sweetalert.min.js"></script>
    <script type="text/javascript">
        function login() {
            var userid = document.getElementById("userid").value;
            var password = document.getElementById("password").value;
            var list = document.getElementsByName("inlineRadioOptions");
            var admin = null;
            if(!list[0].checked&&!list[1].checked&&!list[2].checked){
                return;
            }
            for(var i = 0 ; i < list.length ; i++){
                if(list[i].checked){
                    admin = list[i].value;
                }
            }
            
            $.ajax({
                type : "POST",
                data : "userId=" + userid + "&password=" + password +"&admin=" + admin,
                dataType : "json",
                url : "<%=request.getContextPath()%>/user/loginyanzheng",
                success : function(result) {
                    
                    if (result.status == 0) {
                        swal("哦豁","使用者名稱或密碼有誤,請重新輸入!","error");
                    } else {
                        swal({title:"太帥了",text:"登入成功,進入系統!",type:"success"}, 
                            function () {
                            location.href = "/StuSystem_3/user/index";
                        });
                    }
                }
            });
        }
    </script>
</head>
<body bgcolor="#FFFFFF">
    <div class="middle-box text-center loginscreen  ">
        <div >
            <div  class="animated animated lightSpeedIn ">
                <i class="icon iconfont">&#xf0028;</i>
            </div>
            <h3>歡迎使用 學生成績管理系統</h3>
            <form class=" animated rollIn" data-validator-option="{theme:'yellow_right_effect',stopOnError:true}">
                <div class="form-group">
                    <input type="text" class="form-control"  placeholder="使用者名稱" data-rule="使用者名稱:required;digits" id = "userid">
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" placeholder="密碼" data-rule="密碼:required;password" id = "password">
                </div>
                <fieldset>
                    <label class="radio-inline"  >
                      <input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="1" data-rule="checked"> 管理員
                    </label>
                    <label class="radio-inline">
                      <input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="2" > 教師
                    </label>
                    <label class="radio-inline">
                      <input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="3" > 學生
                    </label>
                </fieldset>
                <br/>
                <br/>
                <button type="submit" class="btn btn-primary block full-width " onclick="login();">登 錄</button>
            </form>
            <br/>
            <br/>
            <div class = "animated bounceInLeft">
               
            </div>
        </div>
    </div>
    <div class="part"></div>
</body>
</html>
index.jsp

<!DOCTYPE HTML>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
 <head>
  <title>學生成績管理系統|首頁</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <link href="<%=request.getContextPath()%>/assets/css/dpl-min.css" rel="stylesheet" type="text/css" />
   <link href="<%=request.getContextPath()%>/assets/css/bui-min.css" rel="stylesheet" type="text/css" />
   <link href="<%=request.getContextPath()%>/assets/css/main.css" rel="stylesheet" type="text/css" />
   <script type="text/javascript">
       var index = layer.load(0, {shade: false}); //0代表載入的風格,支援0-2
       
   </script>
 </head>
 <body>
   <div class="header">
    <div class="dl-title"><span class="">學生成績管理系統</span></div>
    <div class="dl-log">歡迎您,<span class="dl-log-user">${userbean.userName}</span>
    <c:choose>
        <c:when test="${userbean.admin == 1}">
            <span class="admin">(管理員)</span>
        </c:when>
    </c:choose>
    <c:choose>
        <c:when test="${userbean.admin == 2}">
            <span class="admin">(教師)</span>
        </c:when>
    </c:choose>
    <c:choose>
        <c:when test="${userbean.admin == 3}">
            <span class="admin">(學生)</span>
        </c:when>
    </c:choose>
        <a href="loginout" title="退出系統" class="dl-log-quit">[退出]</a>
    </div>
   </div>
   <div class="content">
    <div class="dl-main-nav">
      <ul id="J_Nav"  class="nav-list ks-clear">
        <li class="nav-item dl-selected"><div class="nav-item-inner nav-storage">首頁</div></li>
      </ul>
    </div>
    <ul id="J_NavContent" class="dl-tab-conten">
    </ul>
   </div>
  <script type="text/javascript" src="<%=request.getContextPath()%>/assets/js/jquery-1.8.1.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/assets/js/bui-min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/assets/js/config-min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/lib/layer/1.9.3/layer.js"></script>
  <script>
    //學生登入
    if('${userbean.admin}'=='3'){
    BUI.use('common/main',function(){
      var config = [{
          id:'menu',
          homePage:'gy',
          menu:[{
              text:'學生操作',
              items:[
                {id:'cjcx',text:'成績查詢',href:'/StuSystem_3/score/xsgrcjcx?studentId=' + '${userbean.userId}'},
                {id:'xsgrkcgl',text:'學生個人課程管理',href:'/StuSystem_3/score/scoreone?page=1&studentId=' + '${userbean.userId}' },
                {id:'xsgrxxgl',text:'學生個人資訊管理',href:'/StuSystem_3/student/studentone?stuId=' + '${userbean.userId}' },
                {id:'dlmmxg',text:'登入密碼修改',href:'/StuSystem_3/user/dlmmxg'},
                {id:'gy',text:'關於',href:'gy'}
              ]
            }]
          }];
      new PageUtil.MainPage({
        modulesConfig : config
      });
    });
}    
    //教師登入
if('${userbean.admin}'=='2'){
    BUI.use('common/main',function(){
      var config = [{
          id:'menu',
          homePage:'gy',
          menu:[{
              text:'教師操作',
              items:[
                {id:'xsxxgl',text:'學生資訊管理',href:'/StuSystem_3/teacher/teacherlist?page=1'},
                {id:'kcxxgl',text:'課程資訊管理',href:'/StuSystem_3/student/studentlist?page=1'},
                {id:'jsgrxxgl',text:'教師個人資訊管理',href:'/StuSystem_3/teacher/teacherone?teacherId='+'${userbean.userId}'},
                {id:'xscjgl',text:'學生成績管理',href:'/StuSystem_3/score/scorelist?page=1'},
                {id:'dlmmxg',text:'登入密碼修改',href:'/StuSystem_3/user/dlmmxg'},
                {id:'gy',text:'關於',href:'gy'}
              ]
            }]
          }];
      new PageUtil.MainPage({
        modulesConfig : config
      });
    });
}
    //管理員登入
    if('${userbean.admin}'=='1'){
        BUI.use('common/main',function(){
          var config = [{
              id:'menu',
              homePage:'gy',
              menu:[{
                  text:'管理員操作',
                  items:[
                    {id:'jsxxgl',text:'教師資訊管理',href:'/StuSystem_3/teacher/teacherlist?page=1'},
                    {id:'xsxxgl',text:'學生資訊管理',href:'/StuSystem_3/student/studentlist?page=1'},
                    {id:'kcxxgl',text:'課程資訊管理',href:'/StuSystem_3/subject/subjectlist?page=1'},
                    {id:'xscjgl',text:'學生成績管理',href:'/StuSystem_3/score/scorelist?page=1'},
                    {id:'dlmmxg',text:'登入密碼修改',href:'/StuSystem_3/user/dlmmxg'},
                    {id:'gy',text:'關於',href:'gy'}
                  ]
                }]
              }];
          new PageUtil.MainPage({
            modulesConfig : config
          });
        });
    }
  </script>
 </body>
</html>
dlmmxg.jsp

<!DOCTYPE HTML>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="<%=request.getContextPath()%>/css/H-ui.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/css/H-ui.1.x.patch.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/sweetalert/sweetalert.css">
<script src="<%=request.getContextPath()%>/js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/lib/Validform/5.3.2/Validform.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/lib/Validform/5.3.2/passwordStrength-min.js"></script>
<script src="<%=request.getContextPath()%>/js/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript">
$(function(){
    $("#demoform-2").Validform({
        tiptype:2,
        usePlugin:{
            datepicker:{},//日期控制元件校驗;
            passwordstrength:{
                minLen:6,//設定密碼長度最小值,預設為0;
                maxLen:18,//設定密碼長度最大值,預設為30;
                trigger:function(obj,error){
                    //該表單元素的keyup和blur事件會觸發該函式的執行;
                    //obj:當前表單元素jquery物件;
                    //error:所設密碼是否符合驗證要求,驗證不能通過error為true,驗證通過則為false;    
                    //console.log(error);
                    if(error){
                        obj.parent().find(".Validform_checktip").show();
                        obj.parent().find(".passwordStrength").hide();
                    }else{
                        obj.parent().find(".passwordStrength").show();
                    }
                }
            }
        }
    });
});
</script>
<title>教師資訊編輯頁面</title>
</head>
<body>
    <form action="mmxg" method="post" class="form form-horizontal responsive" id="demoform-2">
          <div class="row cl">
            <label class="form-label col-2">舊密碼:</label>
            <div class="formControls col-5">
              <input type="text" name="userId" id = "userId" value="${userbean.userId}"  style="display:none;"/>
              <input type="text" name="admin" id = "admin" value="${userbean.admin}"  style="display:none;"/>
              <input type="password" class="input-text" placeholder="請輸入舊密碼" name="password" id="password" datatype="*6-16" nullmsg="舊密碼不能為空"  value = "">
            </div>
            <div class="col-5">
            </div>
          </div>
          <div class="row cl">
          <label class="form-label col-2">新密碼:</label>
            <div class="formControls col-5">
              <input type="password" class="input-text" autocomplete="off" placeholder="密碼" name="xmm" id="password1" datatype="*6-18" nullmsg="請輸入密碼!" >
            </div>
            <div class="col-5">
            </div>
          </div>
          <div class="row cl">
            <label class="form-label col-2">密碼驗證:</label>
            <div class="formControls col-5">
              <input type="password" class="input-text" autocomplete="off" placeholder="密碼" name="password2" id="password2" recheck="xmm" datatype="*6-18" nullmsg="請再輸入一次密碼!" errormsg="您兩次輸入的密碼不一致!" >
            </div>
            <div class="col-5">
            </div>
          </div>
          <div class="row cl">
            <div class="col-10 col-offset-2">
              <input class="btn btn-primary" type="submit" onclick="tijiao();" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
          </div>
        </form>
</body>
<script type="text/javascript">

if("${status}" == '1'){
    swal({title:"密碼修改成功!",text:"您已經向伺服器了這條資訊!",type:"success"}, 
            function () {
                  location.href = "dlmmxg";
        });
    
}else if("${status}" == '0'){
    swal("哦豁","修改失敗失敗,請確保密碼輸入正確!","error");
}else{}

</script>
</html>

(2)學生模組

StudentBean.java:

package com.stusystem.entity;


public class StudentBean {
    private int stuId;
    private String stuName;
    private String stuSex;
    private String stuSystem;
    private String stuClass;
    private String stuPhone;
    private int page;
    public int getPage() {
        return (page-1)*6;
    }
    public void setPage(int page) {
        this.page = page;
    }
    public int getStuId() {
        return stuId;
    }
    public void setStuId(int stuId) {
        this.stuId = stuId;
    }
    public String getStuName() {
        return stuName;
    }
    public void setStuName(String stuName) {
        this.stuName = stuName;
    }
    public String getStuSex() {
        return stuSex;
    }
    public void setStuSex(String stuSex) {
        this.stuSex = stuSex;
    }
    public String getStuSystem() {
        return stuSystem;
    }
    public void setStuSystem(String stuSystem) {
        this.stuSystem = stuSystem;
    }
    public String getStuClass() {
        return stuClass;
    }
    public void setStuClass(String stuClass) {
        this.stuClass = stuClass;
    }
    public String getStuPhone() {
        return stuPhone;
    }
    public void setStuPhone(String stuPhone) {
        this.stuPhone = stuPhone;
    }
} 
StudentDao.java:

package com.stusystem.dao;
import java.util.List;
import com.stusystem.entity.StudentBean;
public interface StudentDao {
public List<StudentBean> getStudent(StudentBean studentbean) throws Exception;//返回學生資訊的list
public int getstupage(StudentBean studentbean) throws Exception;//分頁處理
public StudentBean getStudentone (StudentBean studentbean) throws Exception;//返回一條學生資訊
public void studentdel(StudentBean studentbean) throws Exception;//刪除一條學生資訊
public void studentadd(StudentBean studentbean) throws Exception;//增加一條學生資訊
public void studentxiugai(StudentBean studentbean) throws Exception;//修改一條學生資訊
}
StudentDao.xml:

```java
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 

<!-- namespace ,DAO的package路徑  -->
<mapper namespace="com.stusystem.dao.StudentDao"> 
    <!-- 查詢出多條學生資訊 -->
    <select id="getStudent" parameterType="com.stusystem.entity.StudentBean" resultType="com.stusystem.entity.StudentBean">
        <if test=" stuName != null and stuName != '' "> SELECT * FROM student where stu_name = #{stuName} limit #{page} , 6 </if>
        <if test=" stuName == null or stuName == '' "> SELECT * FROM student limit #{page} , 6 </if>
    </select>
    <!--分頁處理  -->
    <select id="getstupage" parameterType="com.stusystem.entity.StudentBean" resultType="int">
        <if test=" stuName != null and stuName != '' "> select count(*) from student where stu_name = #{stuName} </if>
        <if test=" stuName == null or stuName == '' "> select count(*) from student </if>
    </select>
    <!--根據id查詢出一條學生資訊-->
    <select id="getStudentone" parameterType="com.stusystem.entity.StudentBean" resultType="com.stusystem.entity.StudentBean" >
        SELECT * FROM student WHERE stu_id=#{stuId}
    </select>
    <!-- 刪除一條學生資訊  -->
    <delete id="studentdel" parameterType="com.stusystem.entity.StudentBean" >
        DELETE FROM student WHERE (stu_id=#{stuId})
    </delete>
    <!-- 修改一條學生資訊 -->
    <update id="studentxiugai" parameterType="com.stusystem.entity.StudentBean">
        UPDATE student SET stu_name=#{stuName}, stu_sex=#{stuSex}, stu_system=#{stuSystem}, stu_phone=#{stuPhone}, stu_class=#{stuClass} WHERE (stu_id=#{stuId})
    </update>
    <!-- 新增一條學生資訊 -->
    <insert id="studentadd" parameterType="com.stusystem.entity.StudentBean">
        INSERT INTO student (stu_name, stu_sex, stu_system, stu_phone, stu_class) VALUES (#{stuName},#{stuSex},#{stuSystem},#{stuPhone},#{stuClass})
    </insert>
</mapper>
StudentController.java

package com.stusystem.controller;

import java.io.IOException;
import java.net.URLDecoder;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.stusystem.dao.StudentDao;
import com.stusystem.entity.StudentBean;

@Controller
@RequestMapping(value = "student")
public class StudentController {
    @Autowired
    private StudentDao studentDao;
//    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:spring-context.xml");
//    StudentDao studentDao = (StudentDao) applicationContext.getBean("studentDao");
    
    //得到學生列表和頁數.返回到學生資訊頁面
    @RequestMapping(value = {"/studentlist"})
    public String getStudent(StudentBean stu,Model model) throws Exception{
        if(stu.getStuName()!=null&&stu.getStuName()!=""){
            stu.setStuName(URLDecoder.decode(stu.getStuName(), "UTF-8"));
        }
        List<StudentBean> stulist = studentDao.getStudent(stu);
        int stupage = studentDao.getstupage(stu);
        model.addAttribute("studentlist", stulist);
        model.addAttribute("stupage", stupage);
        model.addAttribute("studentname", stu.getStuName());
        return "studentlist";
    }
    //得到一個學生資訊。返回到一個學生資訊頁面
    @RequestMapping(value = {"/studentone"})
    public String getStudentone(StudentBean stu,Model model) throws Exception {
        StudentBean studentone = studentDao.getStudentone(stu);
        model.addAttribute("stuone", studentone);
        return "studentone";
    }
    //得到一個學生資訊。返回到學生編輯頁面
    @RequestMapping(value = {"/studenteditor"})
    public String studenteditor(StudentBean stu,Model model) throws Exception {
        if(stu.getStuId()==0){
            return "studenteditor";
        }else{
            StudentBean studentone = studentDao.getStudentone(stu);
            model.addAttribute("studentone", studentone);
            return "studenteditor";
        }
    }
    //刪除學生資訊
    @RequestMapping(value = {"/studentdel"})
    public void studentdel(StudentBean stu,HttpServletResponse response) throws IOException {
        int a = 0;
        try {
            studentDao.studentdel(stu);
        } catch (Exception e) {
            a=a+1;
            response.getWriter().println("{'status':'0'}");
            e.printStackTrace();
        }
        if(a==0){
            response.getWriter().println("{'status':'1'}");
        }else{
        }
    }
    //新增/修改   ( 以是否有stuId來判斷)     學生資訊
    @RequestMapping(value = {"/studentadd"})
    public void studentadd(StudentBean stu,HttpServletResponse response) throws IOException{
        int a = 0;
        try {
            if(stu.getStuId()==0){
                stu.setStuName(URLDecoder.decode(stu.getStuName(), "UTF-8"));
                stu.setStuSystem(URLDecoder.decode(stu.getStuSystem(), "UTF-8"));
                stu.setStuSex(URLDecoder.decode(stu.getStuSex(), "UTF-8"));
                stu.setStuClass(URLDecoder.decode(stu.getStuClass(), "UTF-8"));
                studentDao.studentadd(stu);
            }else{
                stu.setStuName(URLDecoder.decode(stu.getStuName(), "UTF-8"));
                stu.setStuSystem(URLDecoder.decode(stu.getStuSystem(), "UTF-8"));
                stu.setStuSex(URLDecoder.decode(stu.getStuSex(), "UTF-8"));
                stu.setStuClass(URLDecoder.decode(stu.getStuClass(), "UTF-8"));
                studentDao.studentxiugai(stu);
            }
        } catch (Exception e) {
            a=a+1;
            response.getWriter().println("{'status':'0'}");
            e.printStackTrace();
        }
        if(a==0){
            response.getWriter().println("{'status':'1'}");
        }else{
        }
    }
}
studentlist.jsp

<!DOCTYPE HTML>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrap.min.css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/font/iconfont.css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/sweetalert/sweetalert.css">
<script src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script src="<%=request.getContextPath()%>/lib/layer/1.9.3/layer.js"></script>
<script src="<%=request.getContextPath()%>/lib/laypage/1.2/laypage.js"></script>
<script src="<%=request.getContextPath()%>/js/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript">
function del(studentid) {
     swal({
            title: "您確定要刪除這條資訊嗎",
            text: "刪除後將無法恢復,請謹慎操作!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "刪除",
            closeOnConfirm: false
        }, function () {
            if (window.XMLHttpRequest){
                // code for IE7+, Firefox, Chrome, Opera, Safari
                  xmlhttp=new XMLHttpRequest();
              }
            else{// code for IE6, IE5
                  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
              }                                                       //建立XMLHttpRequest物件
            xmlhttp.onreadystatechange=function(){
              if (xmlhttp.readyState==4 && xmlhttp.status==200){
                  var a = eval("("+xmlhttp.responseText+")");
                  if(a.status== 1){
                      swal({title:"刪除成功!",text:"您已經永久刪除了這條資訊!",type:"success"}, 
                                function () {
                                      var b = '${stupage}' ;
                                      b = Math.ceil(b/6) ;
                                      location.href = "studentlist?page=" + b;
                            });
                  }else{
                      swal("哦豁","刪除失敗,請重試!","error");
                  }
                }
              }    ;                                            //伺服器響應時完成相應操作
            xmlhttp.open("post","studentdel?stuId="+studentid,true);
            xmlhttp.send();
        });
}
</script>
<title>學生列表</title>
</head>
<body background="<%=request.getContextPath()%>/images/010.gif">
<div class="container-fluid">
    <div class="row">
      <div class="col-md-4"></div>
      <div class="col-md-4"><h2 class="text-center">學生資訊管理表</h2></div>
      <div class="col-md-4"></div>
    </div>
</div>
        <div class="row">
          <div class="col-md-3">
              <div class="input-group">
              <input type="text" class="form-control" placeholder="輸入學生姓名搜尋" id = "sousuo" value = "${studentname}">
              <span class="input-group-btn">
                <button class="btn btn-default" type="button" onclick="sousuo();">Go!</button>
              </span>
            </div>
          </div>
          <div class="col-md-3"><button type="button" class="btn btn-default" onclick="tianjia();">新增+</button></div>
          <div class="col-md-6"></div>
        </div>
        
    <br/>
    <table class="table table-hover">
        <tr class="info">
            <th>學號</th>
            <th>學生姓名</th>
            <th>學生性別</th>
            <th>所在系</th>
            <th>班級</th>
            <th>電話號碼</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${studentlist}" var="stu">
            <tr>
                <td>${stu.stuId}</td>
                <td>${stu.stuName}</td>
                <td>${stu.stuSex}</td>
                <td>${stu.stuSystem}</td>
                <td>${stu.stuClass}</td>
                <td>${stu.stuPhone}</td>
                <td><button type="button" class="btn btn-info btn-xs" onclick="bianji(${stu.stuId});" ><i class="iconfont">&#xe66e;</i>&nbsp;編輯</button>&nbsp;&nbsp;<button type="button" onclick="del(${stu.stuId});" class="btn btn-danger btn-xs"><i class="iconfont">&#xe614;</i>&nbsp;刪除</button></td>
            </tr>
        </c:forEach>
    </table>
    <div id="page11" style="margin-top:5px; text-align:center;"></div>
</body>
<script src="<%=request.getContextPath()%>/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
laypage({
    cont: 'page11',
    pages: Math.ceil("${stupage}"/6), //可以叫服務端把總頁數放在某一個隱藏域,再獲取。假設我們獲取到的是18 length
    skip: true, //是否開啟跳頁
    skin: '#6699FF',
    curr: function(){ //通過url獲取當前頁,也可以同上(pages)方式獲取
        var page = location.search.match(/page=(\d+)/);
        return page ? page[1] : 1;
    }(), 
    jump: function(e, first){ //觸發分頁後的回撥
        if(!first){ //一定要加此判斷,否則初始時會無限重新整理
            var studengtname = document.getElementById("sousuo").value;
            location.href = '?page='+e.curr + '&stuName=' + encodeURI(encodeURI(studengtname));
        }
    }
});
</script>
<script type="text/javascript">
    function bianji(studentId) {
        layer.open({
            type: 2,
            title: '學生資訊編輯頁面',
            shadeClose: true,
            shade: 0.8,
            shift: 1, //0-6的動畫形式,-1不開啟
            area: ['800px', '80%'],
            content: 'studenteditor?stuId='+ studentId
        });
    }
     function tianjia() {
         layer.open({
                type: 2,
                title: '學生資訊新增頁面',
                shadeClose: true,
                shade: 0.8,
                shift: 1, //0-6的動畫形式,-1不開啟
                area: ['800px', '80%'],
                content: 'studenteditor?stuId=0'
            }); 
    }
</script>
<script type="text/javascript">
    function sousuo() {
        var studentname = document.getElementById("sousuo").value;
        location.href = 'studentlist?stuName='+ encodeURI(encodeURI(studentname)) + '&page=1' ;
    }
</script>
</html>
studentone.jsp

<!DOCTYPE HTML>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrap.min.css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/font/iconfont.css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/sweetalert/sweetalert.css">
<script src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script src="<%=request.getContextPath()%>/lib/layer/1.9.3/layer.js"></script>
<script src="<%=request.getContextPath()%>/lib/laypage/1.2/laypage.js"></script>
<script src="<%=request.getContextPath()%>/js/sweetalert/sweetalert.min.js"></script>
<title>學生資訊列表</title>
</head>
<body background="<%=request.getContextPath()%>/images/010.gif">
<div class="container-fluid">
    <div class="row">
      <div class="col-md-4"></div>
      <div class="col-md-4"><h2 class="text-center">學生個人資訊管理表</h2></div>
      <div class="col-md-4"></div>
    </div>
</div>
    <br/>
    <table class="table table-hover">
        <tr class="info">
            <th>學號</th>
            <th>學生姓名</th>
            <th>學生性別</th>
            <th>所在系</th>
            <th>班級</th>
            <th>電話號碼</th>
            <th>操作</th>
        </tr>
        <tr>
                <td>${stuone.stuId}</td>
                <td>${stuone.stuName}</td>
                <td>${stuone.stuSex}</td>
                <td>${stuone.stuSystem}</td>
                <td>${stuone.stuClass}</td>
                <td>${stuone.stuPhone}</td>
                <td>
                    <button id = "xiugai" type="button" class="btn btn-info btn-xs" οnclick="xiugai();" >
                        <i class="iconfont">&#xe66e;</i>
                        &nbsp;編輯
                    </button>
                </td>
        </tr>
    </table>
</body>
<script type="text/javascript">
function xiugai() {
    layer.open({
        type: 2,
        title: '學生個人資訊修改頁面',
        shadeClose: true,
        shade: 0.8,
        shift: 1, //0-6的動畫形式,-1不開啟
        area: ['800px', '80%'],
        content: 'studenteditor?stuId='+"${stuone.stuId}"
    }); 
}
</script>
</html>
studenteditor.jsp

<!DOCTYPE HTML>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="<%=request.getContextPath()%>/css/H-ui.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/css/H-ui.1.x.patch.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/sweetalert/sweetalert.css">
<script src="<%=request.getContextPath()%>/js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/lib/Validform/5.3.2/Validform.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/lib/Validform/5.3.2/passwordStrength-min.js"></script>
<script src="<%=request.getContextPath()%>/js/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript">
$(function(){
    $("#demoform-2").Validform({
        tiptype:2,
        usePlugin:{
            datepicker:{},//日期控制元件校驗;
            passwordstrength:{
                minLen:6,//設定密碼長度最小值,預設為0;
                maxLen:18,//設定密碼長度最大值,預設為30;
                trigger:function(obj,error){
                    //該表單元素的keyup和blur事件會觸發該函式的執行;
                    //obj:當前表單元素jquery物件;
                    //error:所設密碼是否符合驗證要求,驗證不能通過error為true,驗證通過則為false;    
                    //console.log(error);
                    if(error){
                        obj.parent().find(".Validform_checktip").show();
                        obj.parent().find(".passwordStrength").hide();
                    }else{
                        obj.parent().find(".passwordStrength").show();
                    }
                }
            }
        }
    });
});
</script>
<title>教師資訊編輯頁面</title>
</head>
<body>
    <form action="" method="post" class="form form-horizontal responsive" id="demoform-2">
          <div class="row cl">
            <label class="form-label col-2">姓名:</label>
            <div class="formControls col-5">
              <input type="text" name="studentid" id = "studentid" value="${studentone.stuId}"  style="display:none;"/>
              <input type="text" class="input-text" placeholder="請輸入學生姓名" name="studentname" id="studentname" datatype="s2-5" nullmsg="學生姓名不能為空"  value = "${studentone.stuName}">
            </div>
            <div class="col-5">
            </div>
          </div>
          <div class="row cl">
            <label class="form-label col-2">所在系:</label>
            <div class="formControls col-5">
              <input type="text" class="input-text" placeholder="請輸入學生所在系" name="studentsystem" id="studentsystem" datatype="s2-10" nullmsg="所在系不能為空" value = "${studentone.stuSystem}">
            </div>
            <div class="col-5">
            </div>
          </div>
          <div class="row cl">
            <label class="form-label col-2">電話號碼:</label>
            <div class="formControls col-5">
              <input type="text" class="input-text" autocomplete="off" placeholder="手機號碼" name="studentphone" id="studentphone" datatype="m" nullmsg="電話號碼不能為空" value = "${studentone.stuPhone}">
            </div>
            <div class="col-5">
            </div>
          </div>
          <div class="row cl">
            <label class="form-label col-2">班級:</label>
            <div class="formControls col-5">
              <input type="text" class="input-text" placeholder="請輸入學生班級" name="studentclass" id="studentclass" datatype="s2-10" nullmsg="班級不能為空" value = "${studentone.stuClass}">
            </div>
            <div class="col-5">
            </div>
          </div>
          <div class="row cl">
            <label class="form-label col-2">學生性別:</label>
            <div class="formControls skin-minimal col-5">
              <div class="radio-box">
                <input type="radio" id="sex-1" name="studentsex" value = "男" datatype="*" nullmsg="請選擇性別!">
                <label for="sex-1">男</label>
              </div>
              <div class="radio-box">
                <input type="radio" id="sex-2" name="studentsex" value = "女">
                <label for="sex-2">女</label>
              </div>
            </div>
            <div class="col-5">
            </div>
          </div>
          <div class="row cl">
            <div class="col-10 col-offset-2">
              <input class="btn btn-primary" type="button" οnclick="hehe();" id = "tijiao" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
          </div>
        </form>
</body>
        <script type="text/javascript">
            if('${studentone.stuSex}' =="女"){
                document.getElementById('sex-2').checked="checked";
            }else if('${studentone.stuSex}' =="男") {
                document.getElementById('sex-1').checked="checked";
            }else{
                
            }
        </script>
        <script type="text/javascript">
         function hehe() {
             var studentname = document.getElementById("studentname").value;
             var studentsystem = document.getElementById("studentsystem").value;
             var studentid = document.getElementById("studentid").value;
             if(studentid==""){
                 studentid = 0;
             }
             var studentphone = document.getElementById("studentphone").value;
             var studentclass = document.getElementById("studentclass").value;
             var list = document.getElementsByName("studentsex");
             var studentsex = null;
             for(var i = 0 ; i < list.length ; i++){
                    if(list[i].checked){
                        studentsex = list[i].value;
                    }
                }
             if(studentname==""||studentsystem==""||studentphone==""||studentclass==""||studentsex==""){
                 swal("哦豁","提交失敗,請重試!","error");
                 return;
             }
             if (window.XMLHttpRequest){
                    // code for IE7+, Firefox, Chrome, Opera, Safari
                      xmlhttp=new XMLHttpRequest();
                  }
                else{// code for IE6, IE5
                      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                  }                                                       //建立XMLHttpRequest物件
                xmlhttp.onreadystatechange=function(){
                  if (xmlhttp.readyState==4 && xmlhttp.status==200){
                      var a = eval("("+xmlhttp.responseText+")");
                      if(a.status == 1){
                          swal({title:"提交成功!",text:"您已經向伺服器了這條資訊!",type:"success"}, 
                                    function () {
                                          parent.top.topManager.reloadPage();
                                          parent.layer.closeAll();
                                });
                      }else{
                          swal("哦豁","提交失敗,請重試!","error");
                      }
                    }
                  }    ;                                            //伺服器響應時完成相應操作
                xmlhttp.open("post","studentadd?stuName="+encodeURI(encodeURI(studentname)) + "&stuSystem=" + encodeURI(encodeURI(studentsystem))+ "&stuId=" + studentid + "&stuPhone=" + encodeURI(encodeURI(studentphone))+ "&stuClass=" + encodeURI(encodeURI(studentclass))+ "&stuSex=" + encodeURI(encodeURI(studentsex)) ,true);
                xmlhttp.send();
        }
        </script>
</html>

(3)教師模組

TeacherBean.java

package com.stusystem.entity;
import org.apache.ibatis.type.Alias;
import org.springframework.stereotype.Component;
@Alias("teacherBean")
@Component
public class TeacherBean {
    private int teacherId;
    private String teacherName;
    private String teacherSex;
    private String teacherSystem;
    private String teacherPhone;
    private String teacherEmail;
    public String getTeacherEmail() {
        return teacherEmail;
    }
    public void setTeacherEmail(String teacherEmail) {
        this.teacherEmail = t