0
点赞
收藏
分享

微信扫一扫

基于javaweb+jsp的教务管理系统(JavaWeb MySQL JSP Bootstrap Servlet SSM SpringBoot)

Jonescy 2022-04-14 阅读 101
javamysql

基于javaweb+jsp的教务管理系统(JavaWeb MySQL JSP Bootstrap Servlet SSM SpringBoot)

JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap.

基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可

开发工具:eclipse/idea/myeclipse/sts等均可配置运行

适用

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

                <if test ='studentClass != null'>`student_class`,</if>
                <if test ='studentPhone != null'>`student_phone`,</if>
                <if test ='studentText != null'>`student_text`</if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test ='id != null'>#{id},</if>
                <if test ='studentName != null'>#{studentName},</if>
                <if test ='studentAge != null'>#{studentAge},</if>
                <if test ='studentSex != null'>#{studentSex},</if>
                <if test ='studentNumber != null'>#{studentNumber},</if>
                <if test ='studentClass != null'>#{studentClass},</if>
                <if test ='studentPhone != null'>#{studentPhone},</if>
                <if test ='studentText != null'>#{studentText}</if>
    </trim>
</insert>
        </if>
        1=1
    </where>
</select>
<?xml version="1.0" encoding="UTF-8"?>
<resultMap id="BaseResultMap" type="com.demo.vo.Notice" >
        <result column="id" property="id" />
        <result column="notice_name" property="noticeName" />
        <result column="notice_text" property="noticeText" />
        <result column="notice_type" property="noticeType" />
        <result column="create_date" property="createDate" />
</resultMap>

<sql id="Base_Column_List">
    `id`,`notice_name`,`notice_text`,`notice_type`,`create_date`
</sql>

            this.end = 5;
        }
        if (end > this.totalPage) {
            //比如当前页是倒数第2页或者最后一页,也同样不符合上面这个规则
            this.end = totalPage;
            this.start = end - 5;
        }
    }
}

//get、set方法。
public int getPageNum() {
    return pageNum;
}

public void setPageNum(int pageNum) {
    this.pageNum = pageNum;
}

public int getPageSize() {
    return pageSize;
}

public void setPageSize(int pageSize) {
    this.pageSize = pageSize;
}

}

/**
 * 跳转到列表页面
 *
 * @param request
 * @param response
 */
private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
    //查询列和关键字
    String searchColumn = Util.decode(request, "searchColumn");
    String keyword = Util.decode(request, "keyword");
    Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
    params.put("searchColumn", searchColumn);//要查询的列
    params.put("keyword", keyword);//查询的关键字
    Map<String, Object> map = teacherService.list(params);
    request.getSession().setAttribute("list", map.get("list"));

    Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
    String pageNum = Util.decode(request, "pageNum");//封装分页参数
    com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
    params.put("startIndex", pb.getStartIndex());
    params.put("pageSize", pb.getPageSize());
    List list = (List) teacherService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list

public void setId(Long id) {
    this.id = id;
}
public String getCourseName() {
    return courseName;
}

public void setCourseName(String courseName) {
    this.courseName = courseName;
}
public String getCourseTime() {
    return courseTime;
}

            <if test ='id != null'>`id` = #{id},</if>
            <if test ='username != null'>`username` = #{username},</if>
            <if test ='password != null'>`password` = #{password},</if>
            <if test ='realName != null'>`real_name` = #{realName},</if>
            <if test ='userSex != null'>`user_sex` = #{userSex},</if>
            <if test ='userPhone != null'>`user_phone` = #{userPhone},</if>
            <if test ='userText != null'>`user_text` = #{userText},</if>
            <if test ='userType != null'>`user_type` = #{userType}</if>
    </set>
    WHERE `id` = #{id}
</update>

<!--获取-->
<select id="findById" resultMap="BaseResultMap">
    return courseRoom;
}

public void setCourseRoom(String courseRoom) {
    this.courseRoom = courseRoom;
}
public String getCourseWeek() {
    return courseWeek;
}

public void setCourseWeek(String courseWeek) {
    this.courseWeek = courseWeek;
}
public String getCourseCollege() {
    return courseCollege;
}
<!--新增-->
<insert id="doCreate" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.demo.vo.Student">
    INSERT INTO `t_student`
    <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test ='id != null'>`id`,</if>
                <if test ='studentName != null'>`student_name`,</if>
                <if test ='studentAge != null'>`student_age`,</if>
                <if test ='studentSex != null'>`student_sex`,</if>
                <if test ='studentNumber != null'>`student_number`,</if>
                <if test ='studentClass != null'>`student_class`,</if>
                <if test ='studentPhone != null'>`student_phone`,</if>
                <if test ='studentText != null'>`student_text`</if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test ='id != null'>#{id},</if>
                <if test ='studentName != null'>#{studentName},</if>
                <if test ='studentAge != null'>#{studentAge},</if>
                <if test ='studentSex != null'>#{studentSex},</if>
                <if test ='studentNumber != null'>#{studentNumber},</if>
                <if test ='studentClass != null'>#{studentClass},</if>
                <if test ='studentPhone != null'>#{studentPhone},</if>
</table>
<div style="float: right;padding-right: 10px;color: #515151;"><jsp:include page="split.jsp"/></div>
<?xml version="1.0" encoding="UTF-8"?>
    <input type="hidden" id="id" name="id" value="${vo.id}"/>
    
    <table class="index-content-table-add">
        <tr>
            <td width="12%">姓名:</td><td><input class="index-content-table-td-add" type="text" id="studentName" name="studentName" value="${vo.studentName}"/></td>
        </tr>
        <tr>
            <td width="12%">年龄:</td><td><input class="index-content-table-td-add" type="text" id="studentAge" name="studentAge" value="${vo.studentAge}"/></td>
        </tr>
        <tr>
            <td width="12%">性别:</td>
            <td>
               <input name="studentSex" type="radio" value="男" ${vo.studentSex=='男'?'checked':''}/>&nbsp;&nbsp;&nbsp;男&nbsp;&nbsp;&nbsp;&nbsp;
               <input name="studentSex" type="radio" value="女" ${vo.studentSex=='女'?'checked':''}/>&nbsp;&nbsp;&nbsp;女&nbsp;&nbsp;&nbsp;&nbsp;
            </td>
        </tr>
        <tr>
            <td width="12%">学号:</td><td><input class="index-content-table-td-add" type="text" id="studentNumber" name="studentNumber" value="${vo.studentNumber}"/></td>
private String studentSex;//性别:男/女
private String studentNumber;//学号
private String studentClass;//班级
private String studentPhone;//联系电话
private String studentText;//备注

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}
public String getStudentName() {
                <if test ='studentAge != null'>`student_age`,</if>
                <if test ='studentSex != null'>`student_sex`,</if>
                <if test ='studentNumber != null'>`student_number`,</if>
                <if test ='studentClass != null'>`student_class`,</if>
                <if test ='studentPhone != null'>`student_phone`,</if>
                <if test ='studentText != null'>`student_text`</if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test ='id != null'>#{id},</if>
                <if test ='studentName != null'>#{studentName},</if>
                <if test ='studentAge != null'>#{studentAge},</if>
                <if test ='studentSex != null'>#{studentSex},</if>
                <if test ='studentNumber != null'>#{studentNumber},</if>
                <if test ='studentClass != null'>#{studentClass},</if>
                <if test ='studentPhone != null'>#{studentPhone},</if>
                <if test ='studentText != null'>#{studentText}</if>
    </trim>
</insert>

<!--批量删除-->
<delete id="doRemoveBatch" parameterType="java.util.Collection">
                <c:when test="${fn:length(vo.studentText) > 19}">
                    <c:out value="${fn:substring(vo.studentText, 0, 19)}..."/>
                </c:when>
                <c:otherwise>
                    <c:out value="${vo.studentText}"/>
                </c:otherwise>
            </c:choose>
            </td>
            <td>
                <button class="btn btn-rect btn-grad btn-warning btn-sm" style="padding: 0px 1px;" onclick="window.location.href='studentGet?id=${vo.id}'">详情</button>&nbsp;
                <button class="btn btn-rect btn-grad btn-default btn-sm" style="padding: 0px 1px;"
                        <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if>
                onclick="window.location.href='studentEditPre?id=${vo.id}'">编辑</button>&nbsp;
                <button class="btn btn-rect btn-grad btn-default btn-sm" style="padding: 0px 1px;" <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if> onclick="if(window.confirm('将要删除:${vo.studentName}?'))window.location.href='studentDelete?id=${vo.id}'">删除</button>
            </td>
    <br>
    <br>
</div>
<br>
<form action="studentEdit" method="post" onsubmit="return check()">
    <input type="hidden" id="id" name="id" value="${vo.id}"/>
    
    <table class="index-content-table-add">
        <tr>
            <td width="12%">姓名:</td><td><input class="index-content-table-td-add" type="text" id="studentName" name="studentName" value="${vo.studentName}"/></td>
        </tr>
        <tr>
            <td width="12%">年龄:</td><td><input class="index-content-table-td-add" type="text" id="studentAge" name="studentAge" value="${vo.studentAge}"/></td>
        </tr>
        <tr>
    vo.setStudentSex(Util.decode(request, "studentSex"));
    vo.setStudentNumber(Util.decode(request, "studentNumber"));
    vo.setStudentClass(Util.decode(request, "studentClass"));
    vo.setStudentPhone(Util.decode(request, "studentPhone"));
    vo.setStudentText(Util.decode(request, "studentText"));
    //调用Service层的增加(insert)方法
    studentService.insert(vo);
    this.redirectList(request, response);
}

/**
 * 删除学生
 *
 * @param response
 * @param request
 * @throws IOException
 */
@RequestMapping("studentDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
    Serializable id = Util.decode(request, "id");
    studentService.delete(Arrays.asList(id));
    this.redirectList(request, response);
}

/**
    SELECT COUNT(*) FROM `t_user`
    <where>
        <if test="searchColumn != null and searchColumn != '' and keyword != null and keyword != ''">
            ${searchColumn} LIKE CONCAT('%',#{keyword},'%')  AND
        </if>
        1=1
    </where>
</select>
<?xml version="1.0" encoding="UTF-8"?>
<resultMap id="BaseResultMap" type="com.demo.vo.Notice" >
        <result column="id" property="id" />
        <result column="notice_name" property="noticeName" />
        <result column="notice_text" property="noticeText" />
        <result column="notice_type" property="noticeType" />
        <result column="create_date" property="createDate" />
</resultMap>
<resultMap id="BaseResultMap" type="com.demo.vo.Student" >
        <result column="id" property="id" />
        <result column="student_name" property="studentName" />
        <result column="student_age" property="studentAge" />
        <result column="student_sex" property="studentSex" />
        <result column="student_number" property="studentNumber" />
        <result column="student_class" property="studentClass" />
        <result column="student_phone" property="studentPhone" />
        <result column="student_text" property="studentText" />
</resultMap>

<sql id="Base_Column_List">
    `id`,`student_name`,`student_age`,`student_sex`,`student_number`,`student_class`,`student_phone`,`student_text`
</sql>

<!--新增-->

运行环境

Java≥6、Tomcat≥7.0、MySQL≥5.5

开发工具

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

技术框架

JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap.

基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可

适用

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

功能说明

登录、注册、退出、用户模块、公告模块、课程模块、学生模块、教师模块的增删改查管理

20220319001751

20220319001752

20220319001753

20220319001754

20220319001755

20220319001756

20220319001757

20220319001758

20220319001759

20220319001800

document

举报

相关推荐

0 条评论