update前端页面demo

thymeleaf update

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" th:href="@{http://static.117.com/css/bootstrap.min.css}"></link>
<link rel="stylesheet" th:href="@{http://static.117.com/css/bootstrap-datetimepicker.css}"></link>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script th:src="@{http://static.117.com/js/jquery-1.10.2.min.js}"></script>
<script th:src="@{http://static.117.com/js/bootstrap.min.js}"></script>
<script th:src="@{http://static.117.com/js/bootstrap-datetimepicker.min.js}" charset="UTF-8"></script>
</head>
<body>
<div class="container">
<div class="row clearfix">
    <div class="col-md-8 column">
        <h1 class="text-center">2元店</h1>
        <form id="form" class="form-horizontal">
            <input type="hidden" name="id" th:value="${product.id}"/>
            <div class="form-group">
                <label class="col-sm-2 control-label">分类:</label>
                <div class="col-sm-10">
                    <select name="cId" class="form-control">
                        <option th:each="category : ${list}" th:value="${category.id}" th:text="${category.name}"
                                th:selected="${category.id == product.CId }"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">商品:</label>
                <div class="col-sm-10">
                    <input name="name" required type="text" class="form-control" th:value="${product.name}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">价格:</label>
                <div class="col-sm-10">
                    <input name="price" required type="text" class="form-control" th:value="${product.price}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">进货日期:</label>
                <div class="col-sm-10">
                    <input id="stockTime" name="stockTime" disabled
                           th:value="${#dates.format(product.stockTime,'yyyy-MM-dd')}" type="text"
                           class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">状态:</label>
                <div class="col-sm-10">
                    <label class="control-label"><input type="radio" name="status" value="1"
                                                        th:checked="${product.status==1}">正常</label>
                    <label class="control-label"><input type="radio" name="status" value="0"
                                                        th:checked="${product.status==0}">禁用</label>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-5 col-sm-5">
                    <button type="button" id="btn" class="btn btn-success" onclick="update()">修改</button>&nbsp;&nbsp;&nbsp;
                    <button type="button" class="btn btn-success" onclick="history.back()">返回</button>
                </div>
            </div>
        </form>
    </div>
</div>
</div>
<script type="text/javascript" th:inline="javascript">
/*<![CDATA[*/
ctxPath = /*[[@{/}]]*/ '';

/*]]>*/

function update() {
    $.ajax({
        url: ctxPath + "update",
        type: "post",
        data: $("#form").serialize(),
        dataType: "json",
        success: function (result) {
            if (result.code == 0) {
                alert("修改成功")
                location.href = ctxPath + "index"
            } else {
                alert(result.msg)
            }
        },
        error: function () {
            alert("服务器没了")
        }
    })
}
</script>
</body>
</html>
//后台逻辑
 @GetMapping("/update-ui/{id}")
public String updateUI(@PathVariable Integer id,Model model){
    Product product = productService.findById(id);
    model.addAttribute("product", product);

    List<Category> list = category();
    model.addAttribute("list", list);

    return "update";
}
@PostMapping("/update")
@ResponseBody
public ResultVO update(Product product){
    productService.update(product);
    return ResultVOUtil.success();
}

thymeleaf index.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>windows首页</title>
<link rel="stylesheet" th:href="@{http://static.117.com/css/bootstrap.min.css}"></link>
<link rel="stylesheet" th:href="@{http://static.117.com/css/bootstrap-datetimepicker.css}"></link>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script th:src="@{http://static.117.com/js/jquery-1.10.2.min.js}"></script>
<script th:src="@{http://static.117.com/js/bootstrap.min.js}"></script>
<script th:src="@{http://static.117.com/js/bootstrap-datetimepicker.min.js}" charset="UTF-8"></script>
</head>
<body>

<div class="container">
<div class="row clearfix">
    <div class="col-md-12 column">
        <h1 class="text-center">2元店</h1>
        <h3 class="text-center">2块钱,你买不了吃亏!2块钱,你买不了上当!</h3>
        <form id="form" th:action="@{/index}" class="form-inline">
            <input type="hidden" name="page" th:id="page"/>
            <div class="form-group">
                <label>分类</label>
                <select id="cId" name="cId" class="form-control">
                    <option th:value="-1">请选择</option>
                    <option th:each="category : ${list}" th:value="${category.id}" th:text="${category.name}"
                            th:selected="${category.id == productFormInfo.CId}"></option>
                </select>
            </div>
            <div class="form-group">
                <label>商品</label>
                <input name="name" type="text" class="form-control"
                       th:value="${productFormInfo.name != null ? productFormInfo.name : ''}">
            </div>
            <div class="form-group span6">
                <label>注册时间</label>
                <input name="startTime" class="form-control" size="10" type="text" id="startTime"
                       th:value="${#dates.format(productFormInfo.startTime,'yyyy-MM-dd')}"> -
                <input name="endTime" class="form-control" size="10" type="text" id="endTime"
                       th:value="${#dates.format(productFormInfo.endTime,'yyyy-MM-dd')}">
            </div>
            <div class="form-group">
                <label>状态</label>
                <select name="status" class="form-control">
                    <option value="-1" th:selected="${productFormInfo == -1}">请选择</option>
                    <option value="1" th:selected="${productFormInfo.status == 1}">销售</option>
                    <option value="0" th:selected="${productFormInfo.status == 0}">下架</option>
                </select>
            </div>
            <div class="form-group">
                <button type="submit" class="btn">查询</button>
                <button type="button" class="btn btn-success"
                        th:onclick="@{'location.href=\'' + ${#httpServletRequest.getContextPath()} + '/add-ui\''}">
                    +添加
                </button>
            </div>
        </form>
        <table class="table table-striped table-bordered" style="margin-top:20px">
            <tr>
                <td>商品ID</td>
                <td>商品名称</td>
                <td>分类</td>
                <td>价格</td>
                <td>进货日期</td>
                <td>状态</td>
                <td>操作</td>
            </tr>
            <tr th:each="product : ${pageInfo.list}">
                <td th:text="${product.id}"></td>
                <td th:text="${product.name}"></td>
                <td th:text="${product.cName}"></td>
                <td th:text="${product.price}+'元'"></td>
                <td th:text="${#dates.format(product.stockTime,'yyyy-MM-dd')}"></td>
                <td th:text="${product.status}"></td>
                <td><a th:href="@{/update-ui/}+${product.id}">修改</a> <a href="javascript:void(0)"
                                                                        th:onclick="del(this,[[${product.id}]])">删除</a>
                </td>
            </tr>
        </table>
        <ul class="pagination">
            <!--不可点击的样式-->
            <li><a href="#" th:onclick="page(1)">首页</a></li>
            <li><a href="#" th:onclick="page([[${pageInfo.pageNum-1}]])">上一页</a></li>
            <li th:each="num : ${pageInfo.getNavigatepageNums()}" th:class="${num==pageInfo.pageNum?'active':''}">
<!--                    <a th:href="@{/index?page=}+${num}" th:text="${num}"></a>-->
                <a href="javascript:void(0)" th:onclick="page([[${num}]])" th:text="${num}"></a>
            </li>
            <li><a href="#" th:onclick="page([[${pageInfo.pageNum+1}]])">下一页</a></li>
            <li><a href="#" th:onclick="page([[${pageInfo.pages}]])">末页</a></li>
        </ul>
    </div>
</div>
</div>

<h1>介个是windows</h1>
<script th:inline="javascript">
$(function () {

    /*<![CDATA[*/
    ctxPath = /*[[@{/}]]*/ '';
    /*]]>*/

    $('#startTime').datetimepicker({
        format: 'yyyy-mm-dd',
        autoclose: true,
        minView: 2
    });
    $('#endTime').datetimepicker({
        format: 'yyyy-mm-dd',
        autoclose: true,
        minView: 2
    });
})

//分页
function page(page) {
    //1.选中隐藏域page,重新赋值
    $("#page").val(page)
    //2.选中form表单,提交
    $("#form").submit();
}

//删除商品信息 obj是按钮的js对象, id是商品的id
function del(obj, id) {
    if (confirm("是否确定删除该商品??")) {
        $.ajax({
            url: ctxPath + "del/" + id,
            type: "DELETE",
            dataType: "json",
            success: function (result) {
                //动态删除指定行
                if (result.code == 0) {
                    $(obj).parent().parent().remove();
                } else {
                    alert(result.msg)
                }
            },
            error: function (result) {
                alert("服务器异常")
            }
        })
    }
}
</script>
</body>
</html>

air maintain.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
 Created by IntelliJ IDEA.
User: 
Date: 2019/5/31
Time: 21:13
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" 	language="java" %>
<html>
<head>
<title>维护页面</title>
<link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row clearfix">
    <div class="col-md-12 column">
        <h3 class="text-center">
            空气质量信息维护页面
        </h3>
        <form action="${pageContext.request.contextPath}/air/update" method="post" class="form-horizontal" role="form">
            <input type="hidden" name="id" value="${air.id}"/>
            <input type="hidden" name="_method" value="put"/>
            <div class="form-group">
                <label for="districtId" class="col-sm-2 control-label">检测区域</label>
                <div class="col-sm-10">
                    <select required class="form-control" name="districtId" id="districtId">
                        <option>-- 请选择 --</option>
                        <c:forEach items="${districtList}" var="d">
                            <option <c:if test="${air.districtId == d.id}">selected</c:if> value="${d.id}">${d.name}</option>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label for="monitorTime" class="col-sm-2 control-label">检测日期</label>
                <div class="col-sm-10">
                    <input required type="date" name="monitorTime" class="form-control" id="monitorTime" value="<fmt:formatDate value='${air.monitorTime}' pattern='yyyy-MM-dd HH:mm:ss'/>"/>
                </div>
            </div>
            <div class="form-group">
                <label for="pm10" class="col-sm-2 control-label">pm10</label>
                <div class="col-sm-10">
                    <input required type="text" class="form-control" id="pm10" name="pm10" value="${air.pm10}"/>
                </div>
            </div>
            <div class="form-group">
                <label for="pm25" class="col-sm-2 control-label">pm2.5</label>
                <div class="col-sm-10">
                    <input required type="text" class="form-control" id="pm25" name="pm25"  value="${air.pm25}"/>
                </div>
            </div>
            <div class="form-group">
                <label for="monitoringStation" class="col-sm-2 control-label">监测站</label>
                <div class="col-sm-10">
                    <input required type="text" class="form-control" id="monitoringStation" name="monitoringStation" value="${air.monitoringStation}"/>
                </div>
            </div>
            <div class="form-group">
                <label for="lastModifyTime" class="col-sm-2 control-label">最后修改时间</label>
                <div class="col-sm-10">
                    <input required type="text" class="form-control" value="<fmt:formatDate value='${air.lastModifyTime}' pattern='yyyy-MM-dd HH:mm:ss'/>" id="lastModifyTime"  />
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" class="btn btn-default">修改</button>
                    <button type="button" onclick="javascript:if(confirm('确认删除该条监测内容吗?')) location.href = '${pageContext.request.contextPath}/air/delete/${air.id}'" class="btn btn-default">删除</button>
                    <button type="button" onclick="history.go(-1);" class="btn btn-default">返回</button>
                </div>
            </div>
        </form>
    </div>
</div>
</div>
</body>
</html>

//后端逻辑
//4.跳转到维护页面.
@GetMapping("maintain/{id}")
public String maintain(@PathVariable Long id,Model model,String updateMsg,String deleteMsg){
    //1.调用service查询指定的空气质量信息.
    Air air = airService.findById(id);
    model.addAttribute("air",air);
    //2.查询全部的区域信息.
    List<District> districtList = districtService.findAll();
    model.addAttribute("districtList",districtList);
    //3.修改时,错误的回显
    model.addAttribute("updateMsg",updateMsg);
    model.addAttribute("deleteMsg",deleteMsg);
    //3.转发页面
    return  "maintain";
}

 //5.执行修改.
@PutMapping("/update")
public String update(@Valid Air air, BindingResult bindingResult,
                     RedirectAttributes redirectAttributes){
    //1.校验参数的合法性
    if(bindingResult.hasErrors()||air.getId()==null){
        //参数不合法
        String msg = bindingResult.getFieldError().getDefaultMessage();
        redirectAttributes.addAttribute("updateMsg",msg != null? msg : "空气质量不能为空");
        return "redirect:/air/maintain/"+air.getId();
    }
    //2.执行修改操作
    Integer count = airService.updateById(air);
    if(count == 1){
        //3.1 修改成功
        return "redirect:/air/list";
    }else{
        //3.2 修改失败
        redirectAttributes.addAttribute("updateMsg","服务器正在更新,请稍后重试");
        return  "redirect:/air/maintain/" + air.getId();
    }
}
//6.删除空气质量信息.
@GetMapping("/delete/{id}")
public String delete(@PathVariable Long id,RedirectAttributes redirectAttributes){
    //1.调用service删除
    Integer count = airService.deleteById(id);
    if(count == 1) {
        //2.1 成功重定向list
        return "redirect:/air/list";
    }else {
        //2.2 返回到维护页面
        redirectAttributes.addAttribute("deleteMsg","服务器正在维护中,请稍后再试");
        return "redirect:/air/maintain/"+id;
    }
}

onlineOA list.jsp

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
Created by IntelliJ IDEA.
 User:	
Date: 2019/06/01
 Time: 21:33:17
 To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>在线问答</title>
<link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row clearfix">
    <div class="col-md-12 column">
        <h1 class="text-center">
            在 线 问 答
        </h1>
        <h3 class="text-center">
            <a href="${pageContext.request.contextPath}/questions/add">我要提问</a>
        </h3>
        <table class="table table-bordered table-hover">
            <thead style="font-size: 18px">
            <tr>
                <th>
                    序号
                </th>
                <th>
                    问题
                </th>
                <th>
                    回答次数
                </th>
                <th>
                    最后修改
                </th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${pageInfo.list}" var="questions" varStatus="vs">
                <tr ${vs.index % 2 == 0 ? 'class="warning"':'class="success"'}>
                    <td>
                        ${vs.index + 1}
                    </td>
                    <td>
                        <a href="${pageContext.request.contextPath}/questions/toAddAnswer/${questions.id}">
                            <span style="${questions.answerCount==0?'color: red':''};font-size: 15px"> ${questions.title}</span>
                        </a>
                    </td>
                    <td>
                        ${questions.answerCount}
                    </td>
                    <td>
                        <fmt:formatDate value="${questions.lastModified}" pattern="yyyy-MM-dd HH:mm:ss"/>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
        <ul class="pagination">
            <c:if test="${pageInfo.page>1}">
                <li>
                    <a href="javascript:;" onclick="page(1)">首页</a>
                </li>
                <li>
                    <a href="javascript:;" onclick="page(${pageInfo.page - 1})">上一页</a>
                </li>
            </c:if>

            <c:if test="${pageInfo.page < pageInfo.pages}">
                <li>
                    <a href="javascript:;" onclick="page(${pageInfo.page + 1})">下一页</a>
                </li>
                <li>
                    <a href="javascript:;" onclick="page(${pageInfo.pages})">尾页</a>
                </li>
            </c:if>
        </ul>
    </div>

    <script>
        function page(page){
            window.location.href="${pageContext.request.contextPath}/questions/list?page="+page;
        }
    </script>
    <span>
        当前第 ${pageInfo.page} 页 / 共 ${pageInfo.pages} 页 (共 ${pageInfo.count} 条)
    </span>
    <div style="color: #b5ff87;font-size: 18px;text-align: center" >
        <span>${queAddMsg}${ansAddMsg}</span>
    </div>

</div>
</div>
</body>
</html>

//后端逻辑
/**
* 1.问题列表(首页)
 */
@RequestMapping("/list")
public String questionsList(@RequestParam(value = "page",defaultValue = "1") Integer page,
                            @RequestParam(value = "size",defaultValue = "2") Integer size,
                            String queAddMsg,
                            String ansAddMsg,
                            Model model){
    //分页查询(获取分页信息)
    PageInfo<Questions> pageInfo = questionsService.findAllQuestionsByPage(page, size);
    //将分页信息添加到request域
    model.addAttribute("pageInfo",pageInfo);
    //将问题信息添加到request域
    model.addAttribute("queAddMsg",queAddMsg);
    //将回答问题成功信息添加到request域
    model.addAttribute("ansAddMsg",ansAddMsg);
    return Constant.QUESTIONS_LIST_PAGE;
}

air list.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
 Date: 2019-05-31
Time: 12:17
 To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>首页</title>
<link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row clearfix">
    <div class="col-md-12 column">
        <h3 class="text-center">
            空气质量检测信息库.
        </h3>
    </div>
</div>
<div class="row clearfix">
    <div class="col-md-6 column">
        <form id="form" action="${pageContext.request.contextPath}/air/list" method="get" class="form-horizontal" role="form">
            <input type="hidden" id="page" name="page" value="1" />
            <div class="form-group">
                <label for="district" class="col-sm-2 control-label">按区域查询</label>
                <div class="col-sm-10">
                    <select name="districtId" class="form-control" id="district" >
                        <option value="0">不限</option>
                        <c:forEach items="${districtList}" var="d">
                        <option <c:if test="${districtId == d.id}">selected</c:if> value="${d.id}">${d.name}</option>
                        </c:forEach>
                    </select>
                    <button type="submit" class="btn btn-default">查询</button>
                </div>
            </div>
        </form>
    </div>
    <div class="col-md-6 column">
        <a href="${pageContext.request.contextPath}/air/add"><h4 class="text-center">添加空气质量信息</h4></a>
    </div>
</div>
<div class="row clearfix">
    <div class="col-md-12 column">
        <c:choose>
            <c:when test="${pageInfo.count > 0}">
                <table class="table table-bordered table-hover">
                    <thead>
                    <tr>
                        <th>
                            序号
                        </th>
                        <th>
                            区域
                        </th>
                        <th>
                            检测时间
                        </th>
                        <th>
                            PM10数据
                        </th>
                        <th>
                            PM2.5数据
                        </th>
                        <th>
                            监测站
                        </th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${pageInfo.list}" var="air" varStatus="i">
                        <tr class="success">
                            <td>${i.index + 1}</td>
                            <td>
                                <a href="${pageContext.request.contextPath}/air/maintain/${air.id}">${air.dname}</a>
                            </td>
                            <td>
                                <fmt:formatDate value="${air.monitorTime}" pattern="yyyy-MM-dd" />
                            </td>
                            <td>${air.pm10}</td>
                            <td>${air.pm25}</td>
                            <td>${air.monitoringStation}</td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>

                <ul class="pagination pagination-lg">
                    <li>
                        <a href="javascript:;" onclick="page(1)">首页</a>
                    </li>
                    <li>
                        <a href="javascript:;" onclick="page(${pageInfo.page - 1})">上一页</a>
                    </li>
                    <li>
                        <a href="javascript:;" onclick="page(${pageInfo.page + 1})">下一页</a>
                    </li>
                    <li>
                        <a href="javascript:;" onclick="page(${pageInfo.pages})">尾页</a>
                    </li>
                </ul>
                <script>
                    function page(num){
                        document.getElementById("page").value = num;
                        document.getElementById("form").submit();
                    }
                </script>
                <span>
                    当前第 ${pageInfo.page} 页 / 共 ${pageInfo.pages} 页 (共 ${pageInfo.count } 条)
                </span>
            </c:when>
            <c:otherwise>
                <h3 class="text-center">
                    抱歉!暂无数据!
                </h3>
            </c:otherwise>
        </c:choose>
    </div>
</div>
</div>
</body>
</html>

//后端逻辑
  //1. 跳转到首页
@RequestMapping("/list")
public String list(Model model,
                   Long districtId,
                   @RequestParam(value = "page",defaultValue = "1")Integer page,
                   @RequestParam(value = "size",defaultValue = "5")Integer size){
    //1. 查询全部区域数据.
    List<District> districtList = districtService.findAll();
    model.addAttribute("districtList",districtList);
    //2. 查询空气质量信息和对应的分页信息.
    PageInfo<Air> pageInfo = airService.findByDistrictIdLimit(districtId, page, size);
    model.addAttribute("pageInfo",pageInfo);
    //3. 数据回显
    model.addAttribute("districtId",districtId);
    //4. 转发到list页面
    return "list";
}

buying.html thymeleaf

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" >
<head>
<meta charset="UTF-8">
<title>订单详情</title>
<link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" th:src="@{/user/js/jquery.min.js}"></script>
</head>
<body>
<div class="container-fluid">
<div class="row-fluid" style="text-align: center">
    <div class="span12">
        <h1 class="text-center" style="text-align: center;color: deepskyblue">
            订单详情
        </h1>
        <div class="col-md-12 column">
            <p class="text-right text-success" th:text="${session.user eq null ? '欢迎您,游客!' : '欢迎您,'+session.user.truename+'!'}">
            </p>
        </div>
        <form class="form-center" role="form">
            <input id="productId" name="productId" th:value="${Product.id}" type="hidden"/>
            <div class="control-group">
                <div class="controls">
                    <label style="display: inline-block" class="control-label" for="name">商品名称</label>
                    <input   disabled="disabled" th:value="${Product.name}" required id="name" name="name" type="text" />
                </div>
            </div>
            <div class="control-group">
                <div class="controls">
                    <label style="display: inline-block" class="control-label" for="product">商品产地</label>
                    <input  disabled="disabled"  th:value="${Product.place}" required id="product" name="product" type="text" />
                </div>
            </div>
            <div class="control-group">
                <div class="controls">
                    <label style="display: inline-block" class="control-label" for="stock">商品库存</label>
                    <input  disabled="disabled" th:value="${Product.stock}" required id="stock" name="stock" type="text" />
                </div>
            </div>
            <div class="control-group">
                <div class="controls">
                    <label style="display: inline-block" class="control-label" for="price">商品单价</label>
                    <input  disabled="disabled" th:value="${Product.price}" required id="price" name="price" type="text" />
                </div>
            </div>
            <div class="control-group">
                <div class="controls">
                    <label style="display: inline-block" class="control-label" for="productQuantity" >购买数量</label>
                    <input  id="productQuantity" name="productQuantity" type="text" th:onchange="calc()"  th:placeholder="请输入购买数量"/>
                </div>
            </div>
            <div class="control-group">
                <div class="controls">
                    <label style="display: inline-block" class="control-label" for="orderTotal" >订单总价</label>
                    <input  disabled="disabled" id="orderTotal" name="orderTotal" th:value="0"/>
                </div>
            </div>
            <div class="control-group">
                <div class="controls">
                    <button type="button" onclick="buy()" class="btn btn-danger">购买</button>
                    <button type="button" onclick="history.back();" class="btn btn-danger">返回</button>
                </div>
            </div>
        </form>
    </div>
</div>
</div>
</body>
<script type="text/javascript">

$(function(){
    calc();
})
//计算总价
function calc() {
    var  price=$("#price").val();
    productQuantity = $("#productQuantity").val();
    orderTotal = price * productQuantity;
    // alert(price + "..." + productQuantity+"..."+orderTotal)
    $("#orderTotal").val(orderTotal);
}

function  buy() {
    var stock = $("#stock").val();
    if (Number(stock) < Number(productQuantity)){
        alert("库存不足,仅剩"+stock);
        $("#productQuantity").val(stock);
        calc();
        return;
    }

    $.ajax({
        url: "/buy/order/add",
        data: {
            "productId" : $("#productId").val(),
            "productQuantity" : productQuantity,
            "orderTotal" : orderTotal,
        },
        type: "post",
        dataType: "json",
        success: function(result){
            if(result.code == 200){
                location.href="/buy/order/orderlist";
            }else {
                alert(result.msg);
            }
        },
        error: function () {
            alert("服务器爆炸!!!")
        }
    });
}
</script>
</html>

list.html thymeleaf

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" >
<head>
<meta charset="UTF-8">
<title>首页商品列表</title>
<link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="/user/js/jquery.min.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="container-fluid">
    <div class="col-md-12 column">
        <div class="row-fluid">
            <div class="span12">
                <h1 class="text-center" style="text-align: center;color: blue">
                    商品信息列表
                </h1>
            </div>
            <div class="col-md-12 column">
                <p class="text-right text-success" th:text="${session.user eq null ? '欢迎您,游客!' : '欢迎您,'+session.user.truename+'!'}">
                </p>
            </div>
        </div>
        <div class="row-fluid">
            <div class="col-md-12 column">
                <form id="form" th:action="@{/buy/product/list}" method="get" class="form-horizontal">
                    <input id="page" name="page" value="1" type="hidden"/>
                    <div class="col-md-12 column">
                        <div class="col-md-12 column">
                            <label class="control-label" for="name" style="color: red">商品名称</label>
                            <input id="name" name="name" th:value="${name}" type="text" th:style="'width:85%;'"/>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <button type="submit" class="btn" style="color: deepskyblue">查询</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="row-fluid">
            <div class="span12">
                <table class="table table-hover table-bordered">
                    <thead >
                    <tr style="background-color: yellow">
                        <th>
                            商品编号
                        </th>
                        <th>
                            商品名称
                        </th>
                        <th>
                            商品价格
                        </th>
                        <th>
                            商品产地
                        </th>
                        <th>
                            商品库存
                        </th>
                        <th>
                            操作
                        </th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr  th:class="${proStatus.even} ? 'error':'info'" th:each="Product,proStatus: ${pageInfo.list}" >

                        <td th:text="${Product.id}"></td>
                        <td th:text="${Product.name}"></td>
                        <td th:text="${Product.price}"></td>
                        <td th:text="${Product.place}"></td>
                        <td th:text="${Product.stock}"></td>
                        <td >
                            <a th:href="'buying?id=' + ${Product.id}">购买</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="col-md-12 column" style="text-align: center">
                <ul class="pagination">
                    <li>
                        <a href="javascript:;" th:onclick="page(1)">首页</a>
                    </li>
                    <li th:if="${pageInfo.pageNum} > 1">
                        <a href="javascript:;" th:onclick="'page('+${pageInfo.pageNum - 1}+')'">上一页</a>
                    </li>

                    <li th:if="${pageInfo.pageNum} < ${pageInfo.pages}">
                        <a href="javascript:;" th:onclick="'page('+${pageInfo.pageNum + 1}+')'">下一页</a>
                    </li>
                    <li>
                        <a href="javascript:;" th:onclick="'page('+${pageInfo.pages}+')'">尾页</a>
                    </li>
                </ul>
                <p >当前第 <b><i style=" font-style:normal;color: maroon" th:text="${pageInfo.pageNum}"></i></b> 页 / 共 <b><i style=" font-style:normal;color: maroon" th:text="${pageInfo.pages}"></i></b> 页 (共 <b><i style=" font-style:normal;color: maroon" th:text="${pageInfo.total}"></i></b> 条)</p>
            </div>
        </div>
    </div>
</div>
</div>
</body>
<script>
//分页
function page(pageNum) {
    //1.选中form表单中的隐藏域,赋值.
    document.getElementById("page").value = pageNum;
    //2.选中form标签对象,手动提交.
    document.getElementById("form").submit();
}
</script>
</body>
</html>

exam1 list.jsp

<%--
 Created by IntelliJ IDEA.
 User: WisemanDong
Date: 2019/8/21
 Time: 20:48
To change this template use File | Settings | File Templates.
--%>
<%@ 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" %>
<html>
<head>
<title>首页</title>
<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/bootstrap.min.css"/>
<%--<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/jeui.css">--%>
</head>
<body>
<div class="container">
<div class="row clearfix">
    <div class="col-md-12 column">
        <h2 class="text-info text-center">
            信息列表
        </h2>
        <form id="form" action="${pageContext.request.contextPath}/game/list" method="get">
            <input type="hidden" name="page" id="page" value="1">
            <div class="col-md-12 column">
                <div class="row clearfix">
                    <div   class="col-md-2 column">
                        <label for="gid">游戏</label>
                        <select type="email"  id="gid" name="gid" style="display: inline-block;width: 100px;text-align: center;text-align-last: center;height: 27px;">
                            <option value="-1"  hidden="hidden" >请选择</option>
                            <option value="-1" <c:if test="${gid == -1}">selected</c:if> >全部</option>
                            <c:forEach items="${games}" var="s">
                                <option value="${s.id}" <c:if test="${game.gid == s.id}">selected</c:if> style="text-align: center">
                                    ${s.gname}
                                </option>
                            </c:forEach>
                        </select>
                    </div>
                    <div   class="col-md-5 column">
                        <label for="name">角色名</label>
                        <input type="text" size="20px"  id="name" name="name" value="${game.name}"/>
                    </div>
                </div>
            </div>
            <div class="col-md-12 column">
                <div class="row clearfix">
                    <div   class="col-md-6 column">
                        <label for="firstdate" style="display: inline">注册时间</label>
                        <input style="display: inline-block" type="date" size="16px"  id="firstdate" name="firstdate" value="<fmt:formatDate value="${game.firstdate}" pattern="yyyy-MM-dd"/>"/>&nbsp;—
                        <input style="display: inline-block" type="date" size="16px" id="seconddate" name="seconddate" value="<fmt:formatDate value="${game.seconddate}" pattern="yyyy-MM-dd"/>"/>
                    </div>
                    <div   class="col-md-3 column">
                        <label for="state">状态</label>
                        <select type="password"  id="state" name="state" style="display: inline-block;width: 100px;text-align: center;text-align-last: center;height: 27px;">
                            <option value="-1"  hidden="hidden" >请选择</option>
                            <option value="-1" <c:if test="${game.state == -1}">selected</c:if> >全部</option>
                            <option value="1" <c:if test="${game.state == 1}">selected</c:if> >正常</option>
                            <option value="0" <c:if test="${game.state == 0}">selected</c:if> >封号</option>
                        </select>
                    </div>
                    <div class="col-md-3 column">
                        <button type="submit" class="btn btn-default" style="height: 30px; width: 65px;padding-top: 5px;">查询</button>
                        <button type="button" class="btn btn-success" style="height: 30px; width: 65px;padding-top: 5px;"
                                onclick="location.href = '${pageContext.request.contextPath}/game/add'">+添加</button>
                    </div>
                </div>
            </div>
        </form>
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th>
                    角色ID
                </th>
                <th>
                    角色名
                </th>
                <th>
                    角色等级
                </th>
                <th>
                    所属游戏
                </th>
                <th>
                    注册日期
                </th>
                <th>
                    状态
                </th>
                <th>
                    操作
                </th>
            </tr>
            </thead>
            <tbody>
                <c:forEach items="${pageInfo.list}" var="game">
                    <tr class="success">
                        <td>
                            ${game.id}
                        </td>
                        <td>
                            ${game.name}
                        </td>
                        <td>
                            ${game.level}
                        </td>
                        <td>
                            <fmt:formatDate value="${game.createdate}" pattern="yyyy-MM-dd hh:mm:ss"></fmt:formatDate>
                        </td>
                        <td>
                            ${game.gname}
                        </td>
                        <td>
                            <c:if test="${game.state == 1}">
                                正常
                            </c:if>
                            <c:if test="${game.state == 0}">
                                封号
                            </c:if>
                        </td>
                        <td>
                            <a href="javascript:;" onclick="location.href='${pageContext.request.contextPath}/game/update/${game.id}'" >修改</a>
                            <a href="javascript:;" onclick="del(${game.id},this)" >删除</a>
                        </td>
                    </tr>
                </c:forEach>
            </tbody>
        </table>
        <div style="text-align: center">
            <ul class="pagination">
                <c:if test="${pageInfo.page > 1}">
                    <li>
                        <a href="javascript:;" onclick="page(1)">首页</a>
                    </li>
                    <li>
                        <a href="javascript:;" onclick="page(${pageInfo.page - 1})">上一页</a>
                    </li>
                </c:if>
                <c:if test="${pageInfo.page < pageInfo.pages}">
                    <li>
                        <a href="javascript:;" onclick="page(${pageInfo.page + 1})">下一页</a>
                    </li>
                    <li>
                        <a href="javascript:;" onclick="page(${pageInfo.pages})">尾页</a>
                    </li>
                </c:if>
            </ul>
        </div>
        <p style="font-size: 20px;text-align: center">当前第 ${pageInfo.page} 页 / 共 ${pageInfo.pages} 页  (${pageInfo.total}条)</p>
    </div>
</div>
</div>
</body>
<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/jquery.min.js">	</script>
<%--<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/jedate.js"></script>--%>
<script type="text/javascript">

// jeDate("#firstdate",{
//     isinitVal:true,
//     festival: true,
//     format: 'YYYY-MM-DD hh:mm:ss'
// });

//分页
function page(page) {
    //1.给隐藏域赋值
    $("#page").val(page);
    //2.提交表单
    $("#form").submit();
}

//删除
function del(id,obj){
    if(confirm("您是否确定删除该人员?")){
        $.ajax({
            url: "${pageContext.request.contextPath}/game/del/"+id,
            data: null,
            type: "DELETE",
            dataType: "json",
            success: function (result) {
                if (result.success == 1){
                    //删除成功
                    $(obj).parent().parent().remove();
                    alert("恭喜,删除成功!")
                } else{
                    //删除失败
                    alert("您删除失败了!");
                }
            },
            error: function () {
                alert("服务器爆炸!");
            }
        });
    }
}
</script>
</html>

exam1 add.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
 Created by IntelliJ IDEA.
User: WisemanDong
 Date: 2019/8/23
 Time: 17:21
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>添加页面</title>
<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/bootstrap.min.css"/>
</head>
<body>
<div class="container">
<div class="row clearfix">
    <div class="col-md-12 column" style="text-align: center">
        <h2 class="text-info text-center">
            添加页面
        </h2>
        <h6 class="text-center">
            (包含上次添加记录)
        </h6>
        <form role="form" id="form" action="${pageContext.request.contextPath}/game/add" method="post">
            <div class="form-group">
                <label style="display: inline-block;width: 60px" for="gid">游戏</label>
                <select style="display: inline-block;width: 173px;height: 26px" type="email"  id="gid" name="gid">
                    <c:forEach items="${games}" var="s">
                        <option value="${s.id}" <c:if test="${s.id == game.id}">selected</c:if>>
                            ${s.gname}
                        </option>
                    </c:forEach>
                </select>
            </div>
            <div class="form-group">
                <label style="display: inline-block;width: 60px" for="name">角色名</label>
                <input style="display: inline-block" type="text" id="name" name="name" value="${game.name}"/>
            </div>
            <div class="form-group">
                <label style="display: inline-block;width: 60px" for="level">角色等级</label>
                <input style="display: inline-block" type="text"  id="level" name="level" value="${game.level}"/>
            </div>
            <div class="form-group">
                <label style="display: inline-block;width: 60px" for="createdate">注册日期</label>
                <input style="display: inline-block;width: 172px" type="date"  id="createdate" name="creatdate" value="<fmt:formatDate value="${game.createdate}" pattern="yyyy-MM-dd"/>"/>
            </div>
            <div class="form-group">
                <label style="display: inline-block;width: 60px" for="state1">状态</label>
                <label class="control-label" style="width: 86px"><input type="radio" id="state1" name="state" value="1" <c:if test="${game.state == 1}">checked</c:if>/>正常</label>
                <label class="control-label" style="width: 86px"><input type="radio" id="state2" name="state" value="0" <c:if test="${game.state == 0}">checked</c:if>/>禁用</label>
            </div>
            <button type="submit" class="btn btn-success">提交</button>
        </form>
    </div>
</div>
</div>
</body>
</html>

exam1 update.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
 Created by IntelliJ IDEA.
User: WisemanDong
 Date: 2019/8/23
 Time: 21:23
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>修改页面</title>
<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/bootstrap.min.css"/>
</head>
<body>
<div class="container">
<div class="row clearfix">
    <div class="col-md-12 column" style="text-align: center">
        <h2 class="text-info text-center">
            修改页面
        </h2>
        <form role="form" id="form" action="${pageContext.request.contextPath}/game/update" method="post">
            <input id="id" name="id" type="hidden" value="${game.id}">
            <div class="form-group">
                <label style="display: inline-block;width: 60px" for="gid">游戏</label>
                <select style="display: inline-block;width: 173px;height: 26px" type="email"  id="gid" name="gid">
                    <c:forEach items="${games}" var="s">
                        <option value="${s.id}" <c:if test="${s.id == game.id}">selected</c:if>>
                                ${s.gname}
                        </option>
                    </c:forEach>
                </select>
            </div>
            <div class="form-group">
                <label style="display: inline-block;width: 60px" for="name">角色名</label>
                <input style="display: inline-block" type="text" id="name" name="name" value="${game.name}"/>
            </div>
            <div class="form-group">
                <label style="display: inline-block;width: 60px" for="level">角色等级</label>
                <input style="display: inline-block" type="text"  id="level" name="level" value="${game.level}"/>
            </div>
            <div class="form-group">
                <label style="display: inline-block;width: 60px" for="createdate">注册日期</label>
                <input style="display: inline-block;width: 172px" type="date"  id="createdate" name="creatdate" value="<fmt:formatDate value="${game.createdate}" pattern="yyyy-MM-dd"/>" readonly/>
            </div>
            <div class="form-group">
                <label style="display: inline-block;width: 60px" for="state1">状态</label>
                <label class="control-label" style="width: 86px"><input type="radio" id="state1" name="state" value="1" <c:if test="${game.state == 1}">checked</c:if>/>正常</label>
                <label class="control-label" style="width: 86px"><input type="radio" id="state2" name="state" value="0" <c:if test="${game.state == 0}">checked</c:if>/>禁用</label>
            </div>
            <button type="submit" class="btn btn-success">提交</button>
        </form>
    </div>
</div>
</div>
</body>
</html>

vip list.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
<script th:src="@{/js/jquery.min.js}" ></script>
</head>
<body>
<div class="container">
<div class="row clearfix">
    <div class="col-md-12 column" style="text-align: center">
        <h2 class="text-info text-center" th:text="${subject.theme}">
        </h2>
        <p th:text="${subject.visit}+'次查看,共有'+${subject.vote}+'人投票'">
        </p>
        <form th:action="@{/update}" method="get" class="form-horizontal" role="form">
            <input id="id" name="id" th:value="${subject.id}" type="hidden">
            <div class="form-group">
                <div th:each="option,step:${optionsList}" class="col-sm-10" style="text-align: left;margin-left: 150px">
                    <span style="margin-left: 100px;width: 20px" th:text="${step.count}"></span>
                    <input type="radio" th:value="${option.id}" th:text="${option.opt}" id="oid" name="oid" style="margin-left: 30px" />
                    <span th:text="${option.counts}+'票'"></span>
                    <!--<input type="hidden" th:value="${option.counts}/${subject.vote}" id="ca" name="ca">-->
                    <span  id="bai" th:text="${option.ff}+'%'" name="bai">%</span>
                </div>
            </div>
            <button type="submit" id="addBtn" name="addBtn" onclick="add()" class="btn btn-default btn-info">我要投票</button>
            <a href="javascript:;" th:onclick="re()">返回首页</a>
        </form>
    </div>
</div>
</div>
</body>
<script>

function add() {
    var oids = $("input:radio[name='oid']:checked").val();
    var id = $("#id").val();
    if (oids == null){
        alert("请从列表中选择一项以完成投票");
        return;
    }else{
        return $("#addBtn").submit();
    }
    //return $("#addBtn").submit();
}

function re() {
    location.href="/index";
}

function bai(){
    var ca = $("#ca").val();
    // alert(ca);
    caa=Math.round(ca*10000)/100;
    // alert(caa);
    $("#bai").text(caa);
};
</script>
</html>

vip index.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
<script th:src="@{/js/jquery.min.js}" ></script>
</head>
<body>
<div class="container">
<div class="row clearfix">
    <div class="col-md-12 column">
        <h2 class="text-info text-center">
            全部主题 >>>
        </h2>
        <table class="table table-striped table-hover">
            <thead>
            <tr>
                <th>
                    序号
                </th>
                <th>
                    主题
                </th>
                <th>
                    投票/查看
                </th>
                <th>
                    创建时间
                </th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="subject:${subjectsList}" class="success">
                <td th:text="${subject.id}" name="id" id="id"></td>
                <td><a href="javascript:;" th:onclick="vis([[${subject.id}]])" th:text="${subject.theme}"></a> </td>
                <td th:text="${subject.vote}+'/'+${subject.visit}"></td>
                <td th:text="${#dates.format(subject.createdate,'yyyy-MM-dd')}"></td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
</div>
</body>
<script type="text/javascript">
function vis(id) {
    location.href="list?id="+id;
}
</script>
</html>

vip updatelist.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
<script th:src="@{/js/jquery.min.js}" ></script>
</head>
<body>
<div class="container">
<div class="row clearfix">
    <div class="col-md-12 column">
        <h2 class="text-info text-center" th:text="'完成投票:'+${subject.theme}">
        </h2>
        <p style="text-align: center" th:text="${subject.visit}+'次查看,共有'+${subject.vote}+'人投票'">
        </p>
        <table class="table table-striped table-hover">
            <tbody>
            <tr th:each="option,step:${optionsList}" class="success">
                <td th:text="${step.count}"></td>
                <td th:text="${option.opt}"></td>
                <td th:text="${option.counts}"></td>
                <td th:text="${option.ff}+'%'"></td>
            </tr>
            </tbody>
        </table>
        <a href="javascript:;" th:onclick="re()">返回首页</a>
    </div>
</div>
</div>
</body>
<script>
function re() {
    location.href="/index";
}
</script>
</html>

二级联动 controller classes1018

import com.github.pagehelper.PageInfo;
import dongzhiyuan.com.qf.entity.Classes;
import dongzhiyuan.com.qf.entity.Department;
import dongzhiyuan.com.qf.entity.Major;
import dongzhiyuan.com.qf.service.ClassesService;
import dongzhiyuan.com.qf.service.DepartmentService;
import dongzhiyuan.com.qf.service.MajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class ClassesController {

@Resource
private ClassesService classesService;

@Resource
private DepartmentService departmentService;

@Resource
private MajorService majorService;

//首页查询
@RequestMapping("/findall")
public String findByCondition(@RequestParam(defaultValue = "1")int pageindex,
                              String classname,String classnum,
                              ModelMap modelMap){

    List<Department> allDepartment = departmentService.findAllDepartment();
    modelMap.addAttribute("dep",allDepartment);
    PageInfo<Classes> byClassnameLikeAndClassnum = classesService.findByClassnameLikeAndClassnum(pageindex, 3, classname, classnum);
    modelMap.addAttribute("classes",byClassnameLikeAndClassnum);
    modelMap.addAttribute("classname",classname);
    modelMap.addAttribute("classnum",classnum);
    return "Educational/class/list";

}

//详情
@RequestMapping("/findinfo")
public String findInfo(int classid,ModelMap modelMap){
    Classes classesById = classesService.findClassesById(classid);
    modelMap.addAttribute("classinfo",classesById);
    List<Department> allDepartment = departmentService.findAllDepartment();
    modelMap.addAttribute("dep",allDepartment);
    List<Major> allMajor = majorService.findAllMajor();
    modelMap.addAttribute("maj",allMajor);
    return "Educational/class/info";
}

//根据departid联动查询专业
@RequestMapping("/findmajor")
@ResponseBody
public List findbyid(Integer departid){
    List<Major> majorByDepid = majorService.findMajorByDepid(departid);
    return majorByDepid;
}

//获取新增班级页面/二级联动失败
@RequestMapping("/getinsert")
public String getinsertclass(ModelMap modelMap){
    List<Department> allDepartment = departmentService.findAllDepartment();
    modelMap.addAttribute("de",allDepartment);
    List<Major> allMajor = majorService.findAllMajor();
    modelMap.addAttribute("ma",allMajor);
    //List alllist = new ArrayList();
    //for (Department department : allDepartment) {
    //    Map map = new HashMap<>();
    //    Integer departid = department.getDepartid();
    //    List<Major> majorByDepid = majorService.findMajorByDepid(departid);
    //    map.put("departid",departid);
    //    map.put("majorlist",majorByDepid);
    //    alllist.add(map);
    //}
    //modelMap.addAttribute("dmlist",alllist);
    return "Educational/class/add";
}

//新增班级
@RequestMapping("/insertclass")
public String insertclass(Classes classes,ModelMap modelMap){
    Integer integer = classesService.insertClasses(classes);
    if (integer != 0){
        return "redirect:/findall";
    }
    return "redirect:/getinsert";
}

//删除班级
@RequestMapping("/deleteclass")
public String deletebyid(int classid){
    int i = classesService.deleteClasses(classid);
    return "redirect:/findall";
}

/**
 * 获取修改页面
 */
@RequestMapping("/getUpdate")
public String getUpdate(int classid,ModelMap modelMap){
    List<Department> allDepartment = departmentService.findAllDepartment();
    modelMap.addAttribute("de",allDepartment);
    List<Major> allMajor = majorService.findAllMajor();
    modelMap.addAttribute("ma",allMajor);
    Classes classesById = classesService.findClassesById(classid);
    modelMap.addAttribute("cla",classesById);
    return "Educational/class/edit";
}

/**
 * 修改
 */
@RequestMapping("/updateStandard")
public String update(Classes classes,ModelMap modelMap){
    Integer integer = classesService.uopdateClass(classes);
    if (integer != 0){
        return "redirect:/findall";
    }
    return "redirect:/getUpdate?classid="+classes.getClassid();
}
}

二级联动 classes1018 list.jsp

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>学生信息管理平台</title>
<link href="../../Style/StudentStyle.css" rel="stylesheet" type="text/css" />
<link href="../../Script/jBox/Skins/Blue/jbox.css" rel="stylesheet" type="text/css" />
<link href="../../Style/ks.css" rel="stylesheet" type="text/css" />
<link href="../../css/mine.css" type="text/css" rel="stylesheet">
<script src="../../Script/jBox/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../../Script/jBox/jquery.jBox-2.3.min.js" type="text/javascript"></script>
<script src="../../Script/jBox/i18n/jquery.jBox-zh-CN.js" type="text/javascript"></script>
<script src="../../Script/Common.js" type="text/javascript"></script>
<script src="../../Script/Data.js" type="text/javascript"></script>

<script>
function del(){
	confirm("确认删除?");
}

</script>
</head>
<body>
<div class="div_head" style="width: 100%;text-align:center;">
	<span> <span style="float:left">当前位置是:教务中心-》班级管理</span> <span
			style="float: right; margin-right: 8px; font-weight: lighter">
        <a style="text-decoration: blink" href="/getinsert">【新增班级】&emsp;&emsp;&emsp;&emsp;</a>
	</span>
	</span>
</div>

<div class="cztable">
<div>

	<ul class="seachform1">
		<form action="/findall" method="post">
			<li>
				<label>班级名称</label>
				<input name="classname" type="text" class="scinput1" value="${classname}"/>&nbsp;&nbsp;
				<label>班级编号</label>
				<input name="classnum" type="text" class="scinput1" value="${classnum}"/>&nbsp;&nbsp;
				<input  type="submit" class="scbtn" value="查询"/>&nbsp;
			</li>

		</form>
	</ul>

	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tbody><tr style="font-weight: bold;">
			<th  width="8%">
				<input type="checkbox"/>
			</th>
			<th >院系</th>
			<th width="">班级编号</th>
			<th width="">班级名称</th>
			<th width="15%">班主任老师</th>
			<th width="15%">人数</th>
			<th width="15%">班级状态</th>
			<th width="20%">操作</th>
		</tr>
		<c:forEach items="${classes.list}" var="clas">
			<tr id="product1">
				<td  width="8%" align="center">
					<input type="checkbox"/>
				</td>

				<td align="center">
					<c:forEach items="${dep}" var="de">
					<c:if test="${de.departid == clas.deptid}">
						${de.departname}
					</c:if>
					</c:forEach>
				</td>
				<td align="center">${clas.classnum}</td>
				<td align="center">${clas.classname}</td>
				<td align="center">${clas.classteacher}</td>
				<td align="center">${clas.peoplecount}</td>
				<td align="center">${clas.classstate}</td>
				<td align="center">
					<a href="/findinfo?classid=${clas.classid}">详情</a>
					<a href="/getUpdate?classid=${clas.classid}">修改</a>
					<a href="javascript:alert('操作成功');">提交审核</a>
					<a href="/deleteclass?classid=${clas.classid}" class="tablelink"> 删除</a>
				</td>
			</tr>
		</c:forEach>
		<tr>
			<td colspan="20" style="text-align: center;">
				<a href="/findall?classname=${classname}&classnum=${classnum}">首页</a>
				<a href="/findall?pageindex=${classes.prePage==0?1:classes.prePage}&classname=${classname}&classnum=${classnum}">上一页</a>
				<c:forEach begin="1" end="${classes.pages}" var="i">
					<a href="/findall?pageindex=${i}&classname=${classname}&classnum=${classnum}">${i}</a>
				</c:forEach>
				<a href="/findall?pageindex=${classes.nextPage==0?classes.pages:classes.nextPage}&classname=${classname}&classnum=${classnum}">下一页</a>
				<a href="/findall?pageindex=${classes.pages}&classname=${classname}&classnum=${classnum}">尾页</a>
				总页数:${classes.pages}
				总条数:${classes.total}
				当前页:${classes.pageNum}
			</td>
		</tr>
		</tbody>
	</table>
</div>
</div>
</body>
</html>

二级联动 add.jsp classes1018

<%--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
学生信息管理平台
</title>
<link href="../../Style/StudentStyle.css" rel="stylesheet" type="text/css" />
<link href="../../Script/jBox/Skins/Blue/jbox.css" rel="stylesheet" type="text/css" />
<link href="../../Style/ks.css" rel="stylesheet" type="text/css" />
<link href="../../css/mine.css" type="text/css" rel="stylesheet">
<script src="../../Script/jBox/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../../Script/jBox/jquery.jBox-2.3.min.js" type="text/javascript"></script>
<script src="../../Script/jBox/i18n/jquery.jBox-zh-CN.js" type="text/javascript"></script>
<script src="../../Script/Common.js" type="text/javascript"></script>
<script src="../../Script/Data.js" type="text/javascript"></script>
</head>
<body>
	<div class="div_head">
        <span>
            <span style="float:left">当前位置是:教务中心-》班级管理-》新增</span>
            <span style="float:right;margin-right: 8px;font-weight: bold"></span>
        </span>
    </div>
</div>
<div class="cztable">
<form action="/insertclass" method="post">
<table border="1" width="100%" class="table_a">
            
            <tr>
                <td  width="120px;">班级编号:<span style="color:red">*</span>:</td>
                <td>
                   <input type="text" name="classnum" value="201602B" />
                </td>
            </tr>
           
           <tr>
                <td>学院<span style="color:red">*</span>:</td>
                <td>
                    <select name="deptid" id="deptid">
                    <option value="">全部</option>
                    <c:forEach items="${de}" var="d">
                        <option value="${d.departid}"}>${d.departname}</option>
                    </c:forEach>
                </select>
                </td>
            </tr>
            <tr>
                <td>专业<span style="color:red">*</span>:</td>
                <td>
                    <select name="majorid" id="majorid">
                        <option value="">全部</option>
<%--                            <c:forEach items="${ma}" var="m">--%>
<%--                            <option value="${m.majorid}"}>${m.majorname}</option>--%>
<%--                            </c:forEach>--%>
                    </select>
                </td>
            </tr>
            <tr>
                <td>班级名称:<span style="color:red">*</span>:</td>
                <td>
					<input type="text" name="classname" value="2016春篮球" /></td>
            </tr>	
			 <tr>
                <td>开班时间:<span style="color:red">*</span>:</td>
                <td>
					<input type="date" name="classbegin" value="2013-10-10" /></td>
            </tr>
            <tr>
                <td>毕业时间:<span style="color:red">*</span>:</td>
                <td>
					<input type="date" name="classend" value="2013-10-10" /></td>
            </tr>
            <tr>
                <td>简介<span style="color:red">*</span>:</td>
                <td>
                    <textarea name="classcontent"></textarea>
                </td>
            </tr>			
            <tr>
                <td colspan="2" align="center">
                    <input type="submit" value="保存">
                </td>
            </tr>  
        </table>
</form>
</div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">

$(function () {
    $("#deptid").change(function () {
        var val = $("#deptid").val();
        $("#majorid>option:gt(0)").remove();
        $("#classid>option:gt(0)").remove();
        if (val == ''){
            return;
        } else {
            $.getJSON("/findmajor","departid="+val,function (data) {
                $("#majorid>option:gt(0)").remove();
                $.each(data,function (index,element) {
                    var major=$('<option value="'+element.majorid+'">'+element.majorname+'</option>');
                    $("#majorid").append(major);
                })
            })
        }
    })
})
</script>
</html>

二级联动 edit.jsp classes1018

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>
学生信息管理平台
</title>
<link href="../../Style/StudentStyle.css" rel="stylesheet" type="text/css" />
<link href="../../Script/jBox/Skins/Blue/jbox.css" rel="stylesheet" type="text/css" />
<link href="../../Style/ks.css" rel="stylesheet" type="text/css" />
<link href="../../css/mine.css" type="text/css" rel="stylesheet">
<script src="../../Script/jBox/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../../Script/jBox/jquery.jBox-2.3.min.js" type="text/javascript"></script>
<script src="../../Script/jBox/i18n/jquery.jBox-zh-CN.js" type="text/javascript"></script>
<script src="../../Script/Common.js" type="text/javascript"></script>
<script src="../../Script/Data.js" type="text/javascript"></script>
</head>
<body>
	<div class="div_head">
        <span>
            <span style="float:left">当前位置是:教务中心-》班级管理-》新增</span>
            <span style="float:right;margin-right: 8px;font-weight: bold"></span>
        </span>
    </div>
</div>
<div class="cztable">
<form action="/updateStandard" method="post">
<table border="1" width="100%" class="table_a">
            <input name="classid" type="hidden" value="${cla.classid}"/>
            <tr>
                <td  width="120px;">班级编号:<span style="color:red">*</span>:</td>
                <td>
                   <input type="text" name="classnum" value="${cla.classnum}" />
                </td>
            </tr>      
           <tr>
               <td>学院<span style="color:red">*</span>:</td>
               <td>
                   <select name="deptid" id="deptid">
                       <option value="">全部</option>
                       <c:forEach items="${de}" var="d">
                           <option  value="${d.departid}" ${d.departid == cla.deptid?'selected':''}>${d.departname}</option>
                       </c:forEach>
                   </select>
               </td>
            </tr>
            <tr>
                <td>专业<span style="color:red">*</span>:</td>
                <td>
                    <select name="majorid" id="majorid">
                        <option value="">全部</option>
                        <c:forEach items="${ma}" var="m">
                            <option value="${m.majorid}"} ${m.majorid == cla.majorid?'selected':''}>${m.majorname}</option>
                        </c:forEach>
                    </select>
                </td>
            </tr>
           
            <tr>
                <td>班级名称:<span style="color:red">*</span>:</td>
                <td>
					<input type="text" name="classname" value="${cla.classname}" /></td>
            </tr>
			
			 <tr>
                <td>开班时间:<span style="color:red">*</span>:</td>
                <td>
                    <input type="date" name="classbegin" value="<fmt:formatDate value='${cla.classbegin}' pattern='yyyy-MM-dd'></fmt:formatDate>" /></td>
            </tr>
            <tr>
                <td>毕业时间:<span style="color:red">*</span>:</td>
                <td>
					<input type="date" name="classend" value="<fmt:formatDate value='${cla.classend}' pattern='yyyy-MM-dd'></fmt:formatDate>" /></td>
            </tr>
            <tr>
                <td>简介<span style="color:red">*</span>:</td>
                <td>
                    <textarea name="classcontent">${cla.classcontent}</textarea>
                </td>
            </tr>	
            <tr>
                <td colspan="2" align="center">
                    <input type="submit" value="保存">
                </td>
            </tr>  
        </table>
</form>
</div>
        </div>
    </div>
</div>
</body>
</html>

二级联动 info.jsp classes1018

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>
学生信息管理平台
</title>
<link href="../../Style/StudentStyle.css" rel="stylesheet" type="text/css" />
<link href="../../Script/jBox/Skins/Blue/jbox.css" rel="stylesheet" type="text/css" />
<link href="../../Style/ks.css" rel="stylesheet" type="text/css" />
<link href="../../css/mine.css" type="text/css" rel="stylesheet">
<script src="../../Script/jBox/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../../Script/jBox/jquery.jBox-2.3.min.js" type="text/javascript"></script>
<script src="../../Script/jBox/i18n/jquery.jBox-zh-CN.js" type="text/javascript"></script>
<script src="../../Script/Common.js" type="text/javascript"></script>
<script src="../../Script/Data.js" type="text/javascript"></script>
</head>
<body>
	<div class="div_head">
        <span>
            <span style="float:left">当前位置是:教务中心-》班级管理-》新增</span>
            <span style="float:right;margin-right: 8px;font-weight: bold"></span>
        </span>
    </div>
</div>
<div class="cztable">
<form action="/findinfo" method="post">
<table border="1" width="100%" class="table_a">       
            <tr>
                <td  width="120px;">班级编号:<span style="color:red">*</span>:</td>
                <td>
                   <input type="text" name="f_goods_name" value="${classinfo.classnum}" />
                </td>
            </tr>
           
           <tr>
                <td>学院<span style="color:red">*</span>:</td>
               <td align="center">
                   <c:forEach items="${dep}" var="de">
                       <c:if test="${de.departid == classinfo.deptid}">
                           ${de.departname}
                       </c:if>
                   </c:forEach>
               </td>
            </tr>
            <tr>
                <td>专业<span style="color:red">*</span>:</td>
                <td align="center">
                    <c:forEach items="${maj}" var="ma">
                        <c:if test="${ma.majorid == classinfo.majorid}">
                            ${ma.majorname}
                        </c:if>
                    </c:forEach>
                </td>
            </tr>
           
            <tr>
                <td>班级名称:<span style="color:red">*</span>:</td>
                <td>
					<input type="text" name="f_goods_price" value="${classinfo.classname}" /></td>
            </tr>
			
			 <tr>
                <td>开班时间:<span style="color:red">*</span>:</td>
                <td>
                    <input type="text" name="f_goods_price" value="<fmt:formatDate value='${classinfo.classbegin}' pattern='yyyy-MM-dd'></fmt:formatDate>" /></td>
            </tr>
            <tr>
                <td>毕业时间:<span style="color:red">*</span>:</td>
                <td>
					<input type="text" name="f_goods_price" value="<fmt:formatDate value='${classinfo.classend}' pattern='yyyy-MM-dd'></fmt:formatDate>" /></td>
            </tr>
			
            <tr>
                <td>简介<span style="color:red">*</span>:</td>
                <td>
                    <textarea>一个新开辟领域的探讨,探讨摸索</textarea>
                </td>
            </tr>

            <tr>
                <td colspan="2" align="center">
                    <input type="button" value="返回" onclick="history.back();">
                </td>
            </tr>  
        </table>
</form>
</div>
        </div>
    </div>
</div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值