1. 程式人生 > 其它 >基於javaEE的簡單教務系統實現(九)

基於javaEE的簡單教務系統實現(九)

<?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" >
<mapper namespace="com.system.mapper.CollegeMapper" >
  <resultMap id="BaseResultMap" type="com.system.po.College" >
    <id column="collegeID"
property="collegeid" jdbcType="INTEGER" /> <result column="collegeName" property="collegename" jdbcType="VARCHAR" /> </resultMap> <sql id="Example_Where_Clause" > <where > <foreach collection="oredCriteria" item="criteria" separator="or" > <
if test="criteria.valid" > <trim prefix="(" suffix=")" prefixOverrides="and" > <foreach collection="criteria.criteria" item="criterion" > <choose > <when test="criterion.noValue" > and ${criterion.condition}
</when> <when test="criterion.singleValue" > and ${criterion.condition} #{criterion.value} </when> <when test="criterion.betweenValue" > and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} </when> <when test="criterion.listValue" > and ${criterion.condition} <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," > #{listItem} </foreach> </when> </choose> </foreach> </trim> </if> </foreach> </where> </sql> <sql id="Update_By_Example_Where_Clause" > <where > <foreach collection="example.oredCriteria" item="criteria" separator="or" > <if test="criteria.valid" > <trim prefix="(" suffix=")" prefixOverrides="and" > <foreach collection="criteria.criteria" item="criterion" > <choose > <when test="criterion.noValue" > and ${criterion.condition} </when> <when test="criterion.singleValue" > and ${criterion.condition} #{criterion.value} </when> <when test="criterion.betweenValue" > and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} </when> <when test="criterion.listValue" > and ${criterion.condition} <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," > #{listItem} </foreach> </when> </choose> </foreach> </trim> </if> </foreach> </where> </sql> <sql id="Base_Column_List" > collegeID, collegeName </sql> <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.system.po.CollegeExample" > select <if test="distinct" > distinct </if> <include refid="Base_Column_List" /> from college <if test="_parameter != null" > <include refid="Example_Where_Clause" /> </if> <if test="orderByClause != null" > order by ${orderByClause} </if> </select> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > select <include refid="Base_Column_List" /> from college where collegeID = #{collegeid,jdbcType=INTEGER} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > delete from college where collegeID = #{collegeid,jdbcType=INTEGER} </delete> <delete id="deleteByExample" parameterType="com.system.po.CollegeExample" > delete from college <if test="_parameter != null" > <include refid="Example_Where_Clause" /> </if> </delete> <insert id="insert" parameterType="com.system.po.College" > insert into college (collegeID, collegeName) values (#{collegeid,jdbcType=INTEGER}, #{collegename,jdbcType=VARCHAR}) </insert> <insert id="insertSelective" parameterType="com.system.po.College" > insert into college <trim prefix="(" suffix=")" suffixOverrides="," > <if test="collegeid != null" > collegeID, </if> <if test="collegename != null" > collegeName, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides="," > <if test="collegeid != null" > #{collegeid,jdbcType=INTEGER}, </if> <if test="collegename != null" > #{collegename,jdbcType=VARCHAR}, </if> </trim> </insert> <select id="countByExample" parameterType="com.system.po.CollegeExample" resultType="java.lang.Integer" > select count(*) from college <if test="_parameter != null" > <include refid="Example_Where_Clause" /> </if> </select> <update id="updateByExampleSelective" parameterType="map" > update college <set > <if test="record.collegeid != null" > collegeID = #{record.collegeid,jdbcType=INTEGER}, </if> <if test="record.collegename != null" > collegeName = #{record.collegename,jdbcType=VARCHAR}, </if> </set> <if test="_parameter != null" > <include refid="Update_By_Example_Where_Clause" /> </if> </update> <update id="updateByExample" parameterType="map" > update college set collegeID = #{record.collegeid,jdbcType=INTEGER}, collegeName = #{record.collegename,jdbcType=VARCHAR} <if test="_parameter != null" > <include refid="Update_By_Example_Where_Clause" /> </if> </update> <update id="updateByPrimaryKeySelective" parameterType="com.system.po.College" > update college <set > <if test="collegename != null" > collegeName = #{collegename,jdbcType=VARCHAR}, </if> </set> where collegeID = #{collegeid,jdbcType=INTEGER} </update> <update id="updateByPrimaryKey" parameterType="com.system.po.College" > update college set collegeName = #{collegename,jdbcType=VARCHAR} where collegeID = #{collegeid,jdbcType=INTEGER} </update> </mapper>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html>
<html>
<head>
    <title></title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入bootstrap -->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
    <!-- 引入JQuery  bootstrap.js-->
    <script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
</head>
<body>
    <!-- 頂欄 -->
    <jsp:include page="top.jsp"></jsp:include>
    <!-- 中間主體 -->
        <div class="container" id="content">
        <div class="row">
            <jsp:include page="menu.jsp"></jsp:include>
            <div class="col-md-10">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <div class="row">
                            <h1 style="text-align: center;">新增教師資訊</h1>
                        </div>
                    </div>
                    <div class="panel-body">
                        <form class="form-horizontal" role="form" action="${pageContext.request.contextPath}/admin/addTeacher" id="editfrom" method="post">
                              <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">工號</label>
                                <div class="col-sm-10">
                                  <input type="number" class="form-control" id="inputEmail3" name="userid" placeholder="請輸入學號">
                                </div>
                              </div>
                              <div class="form-group">
                                <label for="inputPassword3" class="col-sm-2 control-label">姓名</label>
                                <div class="col-sm-10">
                                  <input type="text" class="form-control" id="inputPassword3" name="username" placeholder="請輸入姓名">
                                </div>
                              </div>
                              <div class="form-group">
                                <label for="inputPassword3" class="col-sm-2 control-label">性別</label>
                                <div class="col-sm-10">
                                    <label class="checkbox-inline">
                                           <input type="radio" name="sex" value="男" checked></label>
                                    <label class="checkbox-inline">
                                        <input type="radio" name="sex" value="女"></label>
                                </div>
                              </div>
                              <div class="form-group">
                                <label for="inputPassword3" class="col-sm-2 control-label">出生年份</label>
                                <div class="col-sm-10">
                                    <input type="date" value="1996-09-02" name="birthyear"/>
                                </div>
                              </div>
                              <div class="form-group">
                                <label for="inputPassword3" class="col-sm-2 control-label" name="degree">學歷:</label>
                                <div class="col-sm-10">
                                    <select class="form-control" name="degree">
                                        <option value="本科">本科</option>
                                        <option value="碩士">碩士</option>
                                        <option value="博士">博士</option>
                                    </select>
                                </div>
                              </div>
                            <div class="form-group">
                                <label for="inputPassword3" class="col-sm-2 control-label" name="title">職稱:</label>
                                <div class="col-sm-10">
                                    <select class="form-control" name="title">
                                        <option value="普通教師">普通教師</option>
                                        <option value="助教">助教</option>
                                        <option value="講師">講師</option>
                                        <option value="副教授">副教授</option>
                                        <option value="教授">教授</option>
                                    </select>
                                </div>
                            </div>
                              <div class="form-group">
                                <label for="inputPassword3" class="col-sm-2 control-label" name="grade">入職時間</label>
                                <div class="col-sm-10">
                                    <input type="date" value="2015-09-02" name="grade"/>
                                </div>
                              </div>
                              <div class="form-group">
                                <label for="inputPassword3" class="col-sm-2 control-label" name="grade">所屬院系</label>
                                <div class="col-sm-10">
                                    <select class="form-control" name="collegeid">
                                        <c:forEach items="${collegeList}" var="item">
                                            <option value="${item.collegeid}">${item.collegename}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                              </div>
                              <div class="form-group" style="text-align: center">
                                <button class="btn btn-default" type="submit">提交</button>
                                <button class="btn btn-default" type="reset">重置</button>
                              </div>
                        </form>
                    </div>
                    
                </div>

            </div>
        </div>
    </div>
    <div class="container" id="footer">
    <div class="row">
        <div class="col-md-12"></div>
    </div>
    </div>
</body>
    <script type="text/javascript">
        $("#nav li:nth-child(3)").addClass("active")
    </script>
</html>