主頁 > 後端開發 > 學生成績管理系統(SSM+MySQL+JSP)

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

2020-09-15 18:49:19 後端開發

開發工具: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="https://www.cnblogs.com/liangmingda/p/${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 = https://www.cnblogs.com/liangmingda/p/{"/login"})
    public String userlogin() {
        return "login";
    }
    //登陸驗證
    @RequestMapping(value = https://www.cnblogs.com/liangmingda/p/{"/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 = https://www.cnblogs.com/liangmingda/p/{"/index"})
    public String index() {
        return "index";
    }
    //回傳關于頁面
    @RequestMapping(value = https://www.cnblogs.com/liangmingda/p/{"/gy"})
    public String guanyu() {
        return "gy";
    }
    //回傳密碼修改頁面
    @RequestMapping(value = https://www.cnblogs.com/liangmingda/p/{"/dlmmxg"})
    public String dlmmxg() {
        return "dlmmxg";
    }
    //修改登錄密碼
    @RequestMapping(value = https://www.cnblogs.com/liangmingda/p/{"/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 = https://www.cnblogs.com/liangmingda/p/{"/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 = https://www.cnblogs.com/liangmingda/p/{"/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 = https://www.cnblogs.com/liangmingda/p/{"/studentone"})
    public String getStudentone(StudentBean stu,Model model) throws Exception {
        StudentBean studentone = studentDao.getStudentone(stu);
        model.addAttribute("stuone", studentone);
        return "studentone";
    }
    //得到一個學生資訊,回傳到學生編輯頁面
    @RequestMapping(value = https://www.cnblogs.com/liangmingda/p/{"/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 = https://www.cnblogs.com/liangmingda/p/{"/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 = https://www.cnblogs.com/liangmingda/p/{"/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 = teacherEmail;
    }
    private int page;
    public int getPage() {
        return (page-1)*6;
    }
    public void setPage(int page) {
        this.page = page;
    }
    public int getTeacherId() {
        return teacherId;
    }
    public void setTeacherId(int teacherId) {
        this.teacherId = teacherId;
    }
    public String getTeacherName() {
        return teacherName;
    }
    public void setTeacherName(String teacherName) {
        this.teacherName = teacherName;
    }
    public String getTeacherSystem() {
        return teacherSystem;
    }
    public String getTeacherSex() {
        return teacherSex;
    }
    public void setTeacherSex(String teacherSex) {
        this.teacherSex = teacherSex;
    }
    public void setTeacherSystem(String teacherSystem) {
        this.teacherSystem = teacherSystem;
    }
    public String getTeacherPhone() {
        return teacherPhone;
    }
    public void setTeacherPhone(String teacherPhone) {
        this.teacherPhone = teacherPhone;
    }
}
TeacherDao.java

package com.stusystem.dao;
import com.stusystem.entity.*;
import java.util.*;
public interface TeacherDao {
public List<TeacherBean> getTeacher(TeacherBean teacherbean) throws Exception;
public int getteapage(TeacherBean teacherbean) throws Exception;//回傳教師資訊有多少頁
public TeacherBean getTeacherone(TeacherBean teacherbean) throws Exception;//根據Id回傳一條教師記錄
public void teacherdel(TeacherBean teacherbean) throws Exception;
public void teacheradd(TeacherBean teacherbean) throws Exception;
public void teacherxiugai(TeacherBean teacherbean) throws Exception;
}
TeacherDao.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"> 
<!-- namespace ,DAO的package路徑  -->
<mapper namespace="com.stusystem.dao.TeacherDao">
<select id="getTeacher" parameterType="teacherBean" resultType="teacherBean">
<if test=" teacherName != null and teacherName != '' "> SELECT * FROM teacher where teacher_name = #{teacherName} limit #{page} , 6 </if>
        <if test=" teacherName == null or teacherName == '' "> SELECT * FROM teacher limit #{page} , 6 </if>
</select>
<!-- 查詢出所有教師資訊可以分為多少頁,在前端做分頁處理  -->
    <select id="getteapage" parameterType="teacherBean" resultType="int">
        <if test=" teacherName != null and teacherName != '' "> select count(*) from `teacher` where teacher_name = #{teacherName} </if>
        <if test=" teacherName == null or teacherName == '' "> select count(*) from `teacher` </if>
    </select>
    <!-- 根據id查詢出一條教師資訊  -->
    <select id="getTeacherone" parameterType="teacherBean" resultType="teacherBean" >
        SELECT * FROM teacher WHERE teacher_id=#{teacherId}
    </select>
    <!-- 洗掉一條教師記錄  -->
    <delete id="teacherdel" parameterType="teacherBean" >
        DELETE FROM `teacher` WHERE (`teacher_id`=#{teacherId})
    </delete>
    <!--修改一條教師記錄  -->
    <update id="teacherxiugai" parameterType="teacherBean">
        UPDATE teacher SET teacher_name=#{teacherName}, teacher_sex=#{teacherSex}, teacher_system=#{teacherSystem}, teacher_phone=#{teacherPhone}, teacher_email=#{teacherEmail} WHERE (teacher_id=#{teacherId})
    </update>
    <!-- 添加一條教師記錄  -->
    <insert id="teacheradd" parameterType="teacherBean">
        INSERT INTO `teacher` (`teacher_name`, `teacher_sex`, `teacher_system`, `teacher_phone`, `teacher_email`) VALUES (#{teacherName},#{teacherSex},#{teacherSystem},#{teacherPhone},#{teacherEmail})
    </insert>
</mapper>
TeacherController,java

package com.stusystem.controller;

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

import javax.servlet.http.HttpServletRequest;
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.TeacherDao;
import com.stusystem.entity.TeacherBean;

@Controller
@RequestMapping("teacher")
public class TeacherController {
     @Autowired
     TeacherDao teacherDao;
     @RequestMapping("/teacherlist")
     public String getTeacher(TeacherBean tea,Model model,HttpServletRequest request) throws Exception{
         if(tea.getTeacherName()!=null&&tea.getTeacherName()!=""){
             tea.setTeacherName(URLDecoder.decode(tea.getTeacherName(), "UTF-8"));
         }
         List<TeacherBean> teacherlist=teacherDao.getTeacher(tea);
         int teapage=teacherDao.getteapage(tea);
         model.addAttribute("teacherlist",teacherlist);
         model.addAttribute("teapage",teapage);
         model.addAttribute("teachername",tea.getTeacherName());
         return "teacherlist";
     }
     @RequestMapping("/teacherone")
     public String getTeacherone(TeacherBean tea,Model model) throws Exception{
         TeacherBean teacherone=teacherDao.getTeacherone(tea);
         model.addAttribute("teaone",teacherone);
         return "teacherone";
     }
     @RequestMapping("/teachereditor")
     public String teachereditor(TeacherBean tea,Model model) throws Exception{
         if(tea.getTeacherId()==0) {
             return "teachereditor";
         }else {
             TeacherBean teacherone=teacherDao.getTeacherone(tea);
             model.addAttribute("teacherone",teacherone);
             return "teachereditor";
         }
     }
     @RequestMapping("/teacherdel")
     public void teacherdel(TeacherBean tea,HttpServletResponse response) throws IOException{
            int a = 0;
            try {
                teacherDao.teacherdel(tea);
            } catch (Exception e) {
                a=a+1;
                response.getWriter().println("{'status':'0'}");
                e.printStackTrace();
            }
            if(a==0){
                response.getWriter().println("{'status':'1'}");
            }else{
            }
         
     }
   //添加一條教師用戶資訊
     @RequestMapping(value = https://www.cnblogs.com/liangmingda/p/{"/teacheradd"})
     public void teacheradd(TeacherBean tea,HttpServletResponse response) throws IOException{
         int a = 0;
         try {
             if(tea.getTeacherId()==0){
                 tea.setTeacherName(URLDecoder.decode(tea.getTeacherName(), "UTF-8"));
                 tea.setTeacherSystem(URLDecoder.decode(tea.getTeacherSystem(), "UTF-8"));
                 tea.setTeacherSex(URLDecoder.decode(tea.getTeacherSex(), "UTF-8"));
                 tea.setTeacherEmail(URLDecoder.decode(tea.getTeacherEmail(), "UTF-8"));
                 teacherDao.teacheradd(tea);
             }else{
                 tea.setTeacherName(URLDecoder.decode(tea.getTeacherName(), "UTF-8"));
                 tea.setTeacherSystem(URLDecoder.decode(tea.getTeacherSystem(), "UTF-8"));
                 tea.setTeacherSex(URLDecoder.decode(tea.getTeacherSex(), "UTF-8"));
                 tea.setTeacherEmail(URLDecoder.decode(tea.getTeacherEmail(), "UTF-8"));
                 teacherDao.teacherxiugai(tea);
             }
         } catch (Exception e) {
             a=a+1;
             response.getWriter().println("{'status':'0'}");
             e.printStackTrace();
         }
         if(a==0){
             response.getWriter().println("{'status':'1'}");
         }else{
         }
     }
}
teacherlist.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(teacherid) {
     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 = '${teapage}' ;
                                      b = Math.ceil(b/6) ;
                                      location.href = "teacherlist?page="+b;
                            });
                  }else{
                      swal("哦豁","洗掉失敗,請重試!","error");
                  }
                }
              }    ;                                            //服務器回應時完成相應操作
            xmlhttp.open("post","teacherdel?teacherId="+teacherid,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" id ="sousuo" placeholder="輸入教師姓名搜索" value = "${teachername}" >
              <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="${teacherlist}" var="tea">
            <tr>
                <td>${tea.teacherId}</td>
                <td>${tea.teacherName}</td>
                <td>${tea.teacherSex}</td>
                <td>${tea.teacherSystem}</td>
                <td>${tea.teacherPhone}</td>
                <td>${tea.teacherEmail}</td>
                <td><button type="button" class="btn btn-info btn-xs" onclick="bianji(${tea.teacherId});" ><i class="iconfont">&#xe66e;</i>&nbsp;編輯</button>&nbsp;&nbsp;<button type="button" onclick="del(${tea.teacherId});" 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("${teapage}"/6), //可以叫服務端把總頁數放在某一個隱藏域,再獲取,假設我們獲取到的是18
    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 teachername = document.getElementById("sousuo").value;
            location.href = '?page='+e.curr + '&teacherName=' + encodeURI(encodeURI(teachername));
        }
    }
});
</script>
<script type="text/javascript">
    function bianji(teacherId) {
        layer.open({
            type: 2,
            title: '教師資訊編輯頁面',
            shadeClose: true,
            shade: 0.8,
            shift: 1, //0-6的影片形式,-1不開啟
            area: ['800px', '80%'],
            content: 'teachereditor?teacherId='+ teacherId
        });
    }
     function tianjia() {
         layer.open({
                type: 2,
                title: '教師資訊編輯頁面',
                shadeClose: true,
                shade: 0.8,
                shift: 1, //0-6的影片形式,-1不開啟
                area: ['800px', '80%'],
                content: 'teachereditor?teacherId=0'
            }); 
    }
</script>
<script type="text/javascript">
    function sousuo() {
        var teachername = document.getElementById("sousuo").value;
        location.href = 'teacherlist?teacherName='+ encodeURI(encodeURI(teachername)) + '&page=1' ;
    }
</script>
</html>
teacherone.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>${teaone.teacherId}</td>
                <td>${teaone.teacherName}</td>
                <td>${teaone.teacherSex}</td>
                <td>${teaone.teacherSystem}</td>
                <td>${teaone.teacherPhone}</td>
                <td>${teaone.teacherEmail}</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: 'teachereditor?teacherId='+"${teaone.teacherId}"
    }); 
}
</script>
</html>
teachereditor.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=""  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="teacherid" id = "teacherid" value="${teacherone.teacherId}"  style="display:none;"/>
              <input type="text" value = "${teacherone.teacherName}" class="input-text" placeholder="請輸入教師姓名" name="teachername" id="teachername" datatype="s2-5" 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="text" class="input-text" placeholder="請輸入教師所在系" name="teachersystem" id="teachersystem" datatype="s2-10" nullmsg="請輸入所在系" value = '${teacherone.teacherSystem}' >
            </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="teacherphone" id="teacherphone" datatype="m" nullmsg="電話號碼不能為空" value = '${teacherone.teacherPhone}'>
            </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="teacheremail" id="teacheremail" datatype="e" nullmsg="請輸入郵箱!" value = '${teacherone.teacherEmail}'>
            </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" value = "男" name="teachersex" datatype="*" nullmsg="請選擇性別!" >
                <label for="sex-1"></label>
              </div>
              <div class="radio-box">
                <input type="radio" id="sex-2" name="teachersex" 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('${teacherone.teacherSex}' ==""){
                document.getElementById('sex-2').checked="checked";
            }else if('${teacherone.teacherSex}' =="") {
                document.getElementById('sex-1').checked="checked";
            }else{
                
            }
        </script>
         <script type="text/javascript">
         function hehe() {
             var teachername = document.getElementById("teachername").value;
             var teachersystem = document.getElementById("teachersystem").value;
             var teacherid = document.getElementById("teacherid").value;
             if(teacherid==""){
                 teacherid = 0;
             }
             var teacherphone = document.getElementById("teacherphone").value;
             var teacheremail = document.getElementById("teacheremail").value;
             var list = document.getElementsByName("teachersex");
             var teachersex = null;
             for(var i = 0 ; i < list.length ; i++){
                    if(list[i].checked){
                        teachersex = list[i].value;
                    }
                }
             if(teachername==""||teachersystem==""||teacherphone==""||teacheremail==""||teachersex==""){
                 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","teacheradd?teacherName="+encodeURI(encodeURI(teachername)) + "&teacherSystem=" + encodeURI(encodeURI(teachersystem))+ "&teacherId=" + encodeURI(encodeURI(teacherid))+ "&teacherPhone=" + encodeURI(encodeURI(teacherphone))+ "&teacherEmail=" + encodeURI(encodeURI(teacheremail))+ "&teacherSex=" + encodeURI(encodeURI(teachersex)) ,true);
                xmlhttp.send();
        }
        </script>
</html>

(4)課程模塊

SubjectBean.java

package com.stusystem.entity;

public class SubjectBean {
private int subjectId;
private String subjectName;
private String teacherName;
private String subjectCredit;
private int page;
public int getPage() {
    return (page-1)*6;
}
public void setPage(int page) {
    this.page = page;
}
public int getSubjectId() {
    return subjectId;
}
public void setSubjectId(int subjectId) {
    this.subjectId = subjectId;
}
public String getSubjectName() {
    return subjectName;
}
public void setSubjectName(String subjectName) {
    this.subjectName = subjectName;
}
public String getTeacherName() {
    return teacherName;
}
public void setTeacherName(String teacherName) {
    this.teacherName = teacherName;
}
public String getSubjectCredit() {
    return subjectCredit;
}
public void setSubjectCredit(String subjectCredit) {
    this.subjectCredit = subjectCredit;
}
}
SubjectDao.java

package com.stusystem.dao;

import java.util.List;

import com.stusystem.entity.SubjectBean;

public interface SubjectDao {
public List<SubjectBean> getSubject(SubjectBean subjectBean) throws Exception;
public int getsbjpage(SubjectBean subjectBean) throws Exception;
public SubjectBean getSubjectone(SubjectBean subjectBean) throws Exception;
public void subjectdel(SubjectBean subjectBean) throws Exception;
public void subjectadd(SubjectBean subjectBean) throws Exception;
public void subjectxiugai(SubjectBean subjectBean) throws Exception;
}
SubjectDao.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.SubjectDao"> 
    <!-- 查詢所有課程資訊的list -->
    <select id="getSubject" parameterType="com.stusystem.entity.SubjectBean" resultType="com.stusystem.entity.SubjectBean">
        <if test=" subjectName != null and subjectName != '' "> SELECT * FROM subject where subject_name = #{subjectName} limit #{page} , 6 </if>
        <if test=" subjectName == null or subjectName == '' "> SELECT * FROM subject limit #{page} , 6 </if>
    </select>
    <!-- 查詢課程資訊共有多少頁,分頁處理 -->
    <select id="getsbjpage" parameterType="com.stusystem.entity.SubjectBean" resultType="int">
        <if test=" subjectName != null and subjectName != '' "> select count(*) from `subject` where subject_name = #{subjectName} </if>
        <if test=" subjectName == null or subjectName == '' "> select count(*) from `subject` </if>
    </select>
    <!-- 查詢一條課程資訊  -->
    <select id="getSubjectone" parameterType="com.stusystem.entity.SubjectBean" resultType="com.stusystem.entity.SubjectBean" >
        SELECT * FROM subject WHERE subject_id=#{subjectId}
    </select>
    <!-- 洗掉一條課程資訊 -->
    <delete id="subjectdel" parameterType="com.stusystem.entity.SubjectBean" >
        DELETE FROM `subject` WHERE (`subject_id`=#{subjectId})
    </delete>
    <!-- 修改一條課程資訊  -->
    <update id="subjectxiugai" parameterType="com.stusystem.entity.SubjectBean">
        UPDATE subject SET subject_name=#{subjectName}, teacher_name=#{teacherName}, subject_credit=#{subjectCredit} WHERE (subject_id=#{subjectId})
    </update>
    <!-- 添加一條課程資訊  -->
    <insert id="subjectadd" parameterType="com.stusystem.entity.SubjectBean">
        INSERT INTO `subject` (`subject_name`, `teacher_name`, `subject_credit`) VALUES (#{subjectName},#{teacherName},#{subjectCredit})
    </insert>
</mapper>
ScoreController.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.SubjectDao;
import com.stusystem.entity.SubjectBean;

@Controller
@RequestMapping("subject")
public class SubjectController {
    @Autowired
    SubjectDao subjectDao;
    @RequestMapping("/subjectlist")
    public String getSubject(SubjectBean sbj,Model model) throws Exception{
        if(sbj.getSubjectName()!=null&&sbj.getSubjectName()!=""){
            sbj.setSubjectName(URLDecoder.decode(sbj.getSubjectName(), "UTF-8"));
        }
        List<SubjectBean> subjectlist=subjectDao.getSubject(sbj);
        int sbjpage=subjectDao.getsbjpage(sbj);
        model.addAttribute("subjectlist",subjectlist);
        model.addAttribute("sbjpage",sbjpage);
        model.addAttribute("subjectName", sbj.getSubjectName());
        return "subjectlist";
    }
    
    @RequestMapping("/subjecteditor")
    public String studenteditor(SubjectBean sbj,Model model) throws Exception {
        if(sbj.getSubjectId()==0){
            return "subjecteditor";
        }else{
            SubjectBean subjectone = subjectDao.getSubjectone(sbj);
            model.addAttribute("subjectone", subjectone);//如subjecteditor.jsp中可用subjectone.sybjectId來獲取課程號
            return "subjecteditor";
        }
    }
    //洗掉一條課程資訊
    @RequestMapping(value = https://www.cnblogs.com/liangmingda/p/{"/subjectdel"})
    public void subjectdel(SubjectBean sbj,HttpServletResponse response) throws IOException {
        int a = 0;
        try {
            subjectDao.subjectdel(sbj);
        } catch (Exception e) {
            a=a+1;
            response.getWriter().println("{'status':'0'}");
            e.printStackTrace();
        }
        if(a==0){
            response.getWriter().println("{'status':'1'}");
        }else{
        }
    }
    //添加一條課程資訊
    @RequestMapping(value = https://www.cnblogs.com/liangmingda/p/{"/subjectadd"})
    public void subjectadd(SubjectBean sbj,HttpServletResponse response) throws IOException{
        int a = 0;
        try {
            if(sbj.getSubjectId()==0){
                sbj.setSubjectName(URLDecoder.decode(sbj.getSubjectName(), "UTF-8"));
                sbj.setTeacherName(URLDecoder.decode(sbj.getTeacherName(), "UTF-8"));
                subjectDao.subjectadd(sbj);
            }else{
                sbj.setSubjectName(URLDecoder.decode(sbj.getSubjectName(), "UTF-8"));
                sbj.setTeacherName(URLDecoder.decode(sbj.getTeacherName(), "UTF-8"));
                subjectDao.subjectxiugai(sbj);
            }
        } catch (Exception e) {
            a=a+1;
            response.getWriter().println("{'status':'0'}");
            e.printStackTrace();
        }
        if(a==0){
            response.getWriter().println("{'status':'1'}");
        }else{
        }
    }
}
subjectlist.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 

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/49416.html

標籤:Java

上一篇:IntelliJ Idea 打不開瀏覽器顯示 please configure facet first

下一篇:SpringBoot的核心組態檔

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【C++】Microsoft C++、C 和匯編程式檔案

    ......

    uj5u.com 2020-09-10 00:57:23 more
  • 例外宣告

    相比于斷言適用于排除邏輯上不可能存在的狀態,例外通常是用于邏輯上可能發生的錯誤。 例外宣告 Item 1:當函式不可能拋出例外或不能接受拋出例外時,使用noexcept 理由 如果不打算拋出例外的話,程式就會認為無法處理這種錯誤,并且應當盡早終止,如此可以有效地阻止例外的傳播與擴散。 示例 //不可 ......

    uj5u.com 2020-09-10 00:57:27 more
  • Codeforces 1400E Clear the Multiset(貪心 + 分治)

    鏈接:https://codeforces.com/problemset/problem/1400/E 來源:Codeforces 思路:給你一個陣列,現在你可以進行兩種操作,操作1:將一段沒有 0 的區間進行減一的操作,操作2:將 i 位置上的元素歸零。最終問:將這個陣列的全部元素歸零后操作的最少 ......

    uj5u.com 2020-09-10 00:57:30 more
  • UVA11610 【Reverse Prime】

    本人看到此題沒有翻譯,就附帶了一個自己的翻譯版本 思考 這一題,它的第一個要求是找出所有 $7$ 位反向質數及其質因數的個數。 我們應該需要質數篩篩選1~$10^{7}$的所有數,這里就不慢慢介紹了。但是,重讀題,我們突然發現反向質數都是 $7$ 位,而將它反過來后的數字卻是 $6$ 位數,這就說明 ......

    uj5u.com 2020-09-10 00:57:36 more
  • 統計區間素數數量

    1 #pragma GCC optimize(2) 2 #include <bits/stdc++.h> 3 using namespace std; 4 bool isprime[1000000010]; 5 vector<int> prime; 6 inline int getlist(int ......

    uj5u.com 2020-09-10 00:57:47 more
  • C/C++編程筆記:C++中的 const 變數詳解,教你正確認識const用法

    1、C中的const 1、區域const變數存放在堆疊區中,會分配記憶體(也就是說可以通過地址間接修改變數的值)。測驗代碼如下: 運行結果: 2、全域const變數存放在只讀資料段(不能通過地址修改,會發生寫入錯誤), 默認為外部聯編,可以給其他源檔案使用(需要用extern關鍵字修飾) 運行結果: ......

    uj5u.com 2020-09-10 00:58:04 more
  • 【C++犯錯記錄】VS2019 MFC添加資源不懂如何修改資源宏ID

    1. 首先在資源視圖中,添加資源 2. 點擊新添加的資源,復制自動生成的ID 3. 在解決方案資源管理器中找到Resource.h檔案,編輯,使用整個專案搜索和替換的方式快速替換 宏宣告 4. Ctrl+Shift+F 全域搜索,點擊查找全部,然后逐個替換 5. 為什么使用搜索替換而不使用屬性視窗直 ......

    uj5u.com 2020-09-10 00:59:11 more
  • 【C++犯錯記錄】VS2019 MFC不懂的批量添加資源

    1. 打開資源頭檔案Resource.h,在其中預先定義好宏 ID(不清楚其實ID值應該設定多少,可以先新建一個相同的資源項,再在這個資源的ID值的基礎上遞增即可) 2. 在資源視圖中選中專案資源,按F7編輯資源檔案,按 ID 型別 相對路徑的形式添加 資源。(別忘了先把檔案拷貝到專案中的res檔案 ......

    uj5u.com 2020-09-10 01:00:19 more
  • C/C++編程筆記:關于C++的參考型別,專供新手入門使用

    今天要講的是C++中我最喜歡的一個用法——參考,也叫別名。 參考就是給一個變數名取一個變數名,方便我們間接地使用這個變數。我們可以給一個變數創建N個參考,這N + 1個變數共享了同一塊記憶體區域。(參考型別的變數會占用記憶體空間,占用的記憶體空間的大小和指標型別的大小是相同的。雖然參考是一個物件的別名,但 ......

    uj5u.com 2020-09-10 01:00:22 more
  • 【C/C++編程筆記】從頭開始學習C ++:初學者完整指南

    眾所周知,C ++的學習曲線陡峭,但是花時間學習這種語言將為您的職業帶來奇跡,并使您與其他開發人員區分開。您會更輕松地學習新語言,形成真正的解決問題的技能,并在編程的基礎上打下堅實的基礎。 C ++將幫助您養成良好的編程習慣(即清晰一致的編碼風格,在撰寫代碼時注釋代碼,并限制類內部的可見性),并且由 ......

    uj5u.com 2020-09-10 01:00:41 more
最新发布
  • Rust中的智能指標:Box<T> Rc<T> Arc<T> Cell<T> RefCell<T> Weak

    Rust中的智能指標是什么 智能指標(smart pointers)是一類資料結構,是擁有資料所有權和額外功能的指標。是指標的進一步發展 指標(pointer)是一個包含記憶體地址的變數的通用概念。這個地址參考,或 ” 指向”(points at)一些其 他資料 。參考以 & 符號為標志并借用了他們所 ......

    uj5u.com 2023-04-20 07:24:10 more
  • Java的值傳遞和參考傳遞

    值傳遞不會改變本身,參考傳遞(如果傳遞的值需要實體化到堆里)如果發生修改了會改變本身。 1.基本資料型別都是值傳遞 package com.example.basic; public class Test { public static void main(String[] args) { int ......

    uj5u.com 2023-04-20 07:24:04 more
  • [2]SpinalHDL教程——Scala簡單入門

    第一個 Scala 程式 shell里面輸入 $ scala scala> 1 + 1 res0: Int = 2 scala> println("Hello World!") Hello World! 檔案形式 object HelloWorld { /* 這是我的第一個 Scala 程式 * 以 ......

    uj5u.com 2023-04-20 07:23:58 more
  • 理解函式指標和回呼函式

    理解 函式指標 指向函式的指標。比如: 理解函式指標的偽代碼 void (*p)(int type, char *data); // 定義一個函式指標p void func(int type, char *data); // 宣告一個函式func p = func; // 將指標p指向函式func ......

    uj5u.com 2023-04-20 07:23:52 more
  • Django筆記二十五之資料庫函式之日期函式

    本文首發于公眾號:Hunter后端 原文鏈接:Django筆記二十五之資料庫函式之日期函式 日期函式主要介紹兩個大類,Extract() 和 Trunc() Extract() 函式作用是提取日期,比如我們可以提取一個日期欄位的年份,月份,日等資料 Trunc() 的作用則是截取,比如 2022-0 ......

    uj5u.com 2023-04-20 07:23:45 more
  • 一天吃透JVM面試八股文

    什么是JVM? JVM,全稱Java Virtual Machine(Java虛擬機),是通過在實際的計算機上仿真模擬各種計算機功能來實作的。由一套位元組碼指令集、一組暫存器、一個堆疊、一個垃圾回收堆和一個存盤方法域等組成。JVM屏蔽了與作業系統平臺相關的資訊,使得Java程式只需要生成在Java虛擬機 ......

    uj5u.com 2023-04-20 07:23:31 more
  • 使用Java接入小程式訂閱訊息!

    更新完微信服務號的模板訊息之后,我又趕緊把微信小程式的訂閱訊息給實作了!之前我一直以為微信小程式也是要企業才能申請,沒想到小程式個人就能申請。 訊息推送平臺🔥推送下發【郵件】【短信】【微信服務號】【微信小程式】【企業微信】【釘釘】等訊息型別。 https://gitee.com/zhongfuch ......

    uj5u.com 2023-04-20 07:22:59 more
  • java -- 緩沖流、轉換流、序列化流

    緩沖流 緩沖流, 也叫高效流, 按照資料型別分類: 位元組緩沖流:BufferedInputStream,BufferedOutputStream 字符緩沖流:BufferedReader,BufferedWriter 緩沖流的基本原理,是在創建流物件時,會創建一個內置的默認大小的緩沖區陣列,通過緩沖 ......

    uj5u.com 2023-04-20 07:22:49 more
  • Java-SpringBoot-Range請求頭設定實作視頻分段傳輸

    老實說,人太懶了,現在基本都不喜歡寫筆記了,但是網上有關Range請求頭的文章都太水了 下面是抄的一段StackOverflow的代碼...自己大修改過的,寫的注釋挺全的,應該直接看得懂,就不解釋了 寫的不好...只是希望能給視頻網站開發的新手一點點幫助吧. 業務場景:視頻分段傳輸、視頻多段傳輸(理 ......

    uj5u.com 2023-04-20 07:22:42 more
  • Windows 10開發教程_編程入門自學教程_菜鳥教程-免費教程分享

    教程簡介 Windows 10開發入門教程 - 從簡單的步驟了解Windows 10開發,從基本到高級概念,包括簡介,UWP,第一個應用程式,商店,XAML控制元件,資料系結,XAML性能,自適應設計,自適應UI,自適應代碼,檔案管理,SQLite資料庫,應用程式到應用程式通信,應用程式本地化,應用程式 ......

    uj5u.com 2023-04-20 07:22:35 more