zoukankan      html  css  js  c++  java
  • 基于javaEE的简单教务系统实现(七)

    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt" %>
    
    
    <!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/editStudent" id="editfrom" method="post">
                                  <div class="form-group ">
                                    <label for="inputEmail3" class="col-sm-2 control-label" >学号</label>
                                    <div class="col-sm-10">
                                      <input readonly="readonly" type="number" class="form-control" id="inputEmail3" name="userid" placeholder="请输入学号"
                                      <c:if test='${student!=null}'>
                                             value="${student.userid}"
                                      </c:if>>
                                    </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="请输入姓名" value="${student.username}">
                                    </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="<fmt:formatDate value="${student.birthyear}" dateStyle="medium" pattern="yyyy-MM-dd" />" name="birthyear"/>
                                    </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="<fmt:formatDate value="${student.grade}" dateStyle="medium" pattern="yyyy-MM-dd" />" 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" id="college">
                                            <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(2)").addClass("active")
    
            var collegeSelect = $("#college option");
            for (var i=0; i<collegeSelect.length; i++) {
                if (collegeSelect[i].value == '${student.collegeid}') {
                    collegeSelect[i].selected = true;
                }
            }
        </script>
    </html>

    学生管理部分类容

    package com.system.controller;
    
    import com.system.exception.CustomException;
    import com.system.po.*;
    import com.system.service.CourseService;
    import com.system.service.SelectedCourseService;
    import com.system.service.StudentService;
    import org.apache.shiro.SecurityUtils;
    import org.apache.shiro.subject.Subject;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    import javax.annotation.Resource;
    import java.util.List;
    
    /**
     * Created by Jacey on 2017/7/5.
     */
    @Controller
    @RequestMapping(value = "/student")
    public class StudentController {
    
        @Resource(name = "courseServiceImpl")
        private CourseService courseService;
    
        @Resource(name = "studentServiceImpl")
        private StudentService studentService;
    
        @Resource(name = "selectedCourseServiceImpl")
        private SelectedCourseService selectedCourseService;
    
        @RequestMapping(value = "/showCourse")
        public String stuCourseShow(Model model, Integer page) throws Exception {
    
            List<CourseCustom> list = null;
            //页码对象
            PagingVO pagingVO = new PagingVO();
            //设置总页数
            pagingVO.setTotalCount(courseService.getCountCouse());
            if (page == null || page == 0) {
                pagingVO.setToPageNo(1);
                list = courseService.findByPaging(1);
            } else {
                pagingVO.setToPageNo(page);
                list = courseService.findByPaging(page);
            }
    
            model.addAttribute("courseList", list);
            model.addAttribute("pagingVO", pagingVO);
    
            return "student/showCourse";
        }
    
        // 选课操作
        @RequestMapping(value = "/stuSelectedCourse")
        public String stuSelectedCourse(int id) throws Exception {
            //获取当前用户名
            Subject subject = SecurityUtils.getSubject();
            String username = (String) subject.getPrincipal();
    
            SelectedCourseCustom selectedCourseCustom = new SelectedCourseCustom();
            selectedCourseCustom.setCourseid(id);
            selectedCourseCustom.setStudentid(Integer.parseInt(username));
    
            SelectedCourseCustom s = selectedCourseService.findOne(selectedCourseCustom);
    
            if (s == null) {
                selectedCourseService.save(selectedCourseCustom);
            } else {
                throw new CustomException("该门课程你已经选了,不能再选");
            }
    
            return "redirect:/student/selectedCourse";
        }
    
        // 退课操作
        @RequestMapping(value = "/outCourse")
        public String outCourse(int id) throws Exception {
            Subject subject = SecurityUtils.getSubject();
            String username = (String) subject.getPrincipal();
    
            SelectedCourseCustom selectedCourseCustom = new SelectedCourseCustom();
            selectedCourseCustom.setCourseid(id);
            selectedCourseCustom.setStudentid(Integer.parseInt(username));
    
            selectedCourseService.remove(selectedCourseCustom);
    
            return "redirect:/student/selectedCourse";
        }
    
        // 已选课程
        @RequestMapping(value = "/selectedCourse")
        public String selectedCourse(Model model) throws Exception {
            //获取当前用户名
            Subject subject = SecurityUtils.getSubject();
            StudentCustom studentCustom = studentService.findStudentAndSelectCourseListByName((String) subject.getPrincipal());
    
            List<SelectedCourseCustom> list = studentCustom.getSelectedCourseList();
    
            model.addAttribute("selectedCourseList", list);
    
            return "student/selectCourse";
        }
    
        // 已修课程
        @RequestMapping(value = "/overCourse")
        public String overCourse(Model model) throws Exception {
    
            //获取当前用户名
            Subject subject = SecurityUtils.getSubject();
            StudentCustom studentCustom = studentService.findStudentAndSelectCourseListByName((String) subject.getPrincipal());
    
            List<SelectedCourseCustom> list = studentCustom.getSelectedCourseList();
    
            model.addAttribute("selectedCourseList", list);
    
            return "student/overCourse";
        }
    
        //修改密码
        @RequestMapping(value = "/passwordRest")
        public String passwordRest() throws Exception {
            return "student/passwordRest";
        }
    
    
    
    }
  • 相关阅读:
    使用samba实现linux和windows文件共享
    使用li列举属性表中的某一属性
    popuptemplate的使用
    html中自动分配界面
    div中移除和添加元素
    使用v-html绑定数据,实现图片的动态转换
    使用js下载数据
    使用FeatureTable对FeatureLayer中的数据进行显示
    使用ant的checkboxGroup将列表信息添加为多选框,并根据多选框的转换进行操作
    arcgis api绘制多个点
  • 原文地址:https://www.cnblogs.com/520520520zl/p/14894300.html
Copyright © 2011-2022 走看看