更新之后,创建时间不见了,问题出现在哪里?老师在视频里把设置创建时间给去掉了
public void update(ClaimVoucher claimVoucher, List<ClaimVoucherItem> items) { claimVoucher.setNextDealSn(claimVoucher.getCreateSn()); claimVoucher.setStatus(Constant.CLAIMVOUCHER_CREATED); claimVoucherDao.update(claimVoucher); List<ClaimVoucherItem> olds=claimVoucherItemDao.selectByClaimVoucher(claimVoucher.getId()); for(ClaimVoucherItem old:olds){ boolean isHave=false; for(ClaimVoucherItem item:items){ if(old.getId()==item.getId()){ isHave=true; break; } } if(!isHave){ claimVoucherItemDao.delete(old.getId()); } } for(ClaimVoucherItem item:items){ item.setClaimVoucherId(claimVoucher.getId()); if(item.getId()!=null&&item.getId()>0){ claimVoucherItemDao.update(item); }else{ claimVoucherItemDao.insert(item); } } }
//去更新 @RequestMapping("/to_update") public String toUpdate(int id,Map<String,Object> map){ map.put("items", Constant.getItems()); ClaimVoucherInfo info=new ClaimVoucherInfo(); info.setClaimVoucher(claimVoucherBiz.get(id)); info.setItems(claimVoucherBiz.getItems(id)); map.put("info",info); return "claim_voucher_update"; } //更新 @RequestMapping("/update") public String update(HttpSession session,ClaimVoucherInfo info){ Employee employee=(Employee)session.getAttribute("employee"); info.getClaimVoucher().setCreateSn(employee.getSn()); claimVoucherBiz.update(info.getClaimVoucher(),info.getItems()); return "redirect:deal"; }
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="top.jsp"/> <section id="content" class="table-layout animated fadeIn"> <div class="tray tray-center"> <div class="content-header"> <h2> 修改报销单 </h2> <p class="lead"></p> </div> <div class="admin-form theme-primary mw1000 center-block" style="padding-bottom: 175px;"> <div class="panel heading-border"> <form:form id="admin-form" name="addForm" modelAttribute="info" action="/claim_voucher/update" > <form:hidden path="claimVoucher.id"/> <div class="panel-body bg-light"> <div class="section-divider mt20 mb40"> <span> 基本信息 </span> </div> <div class="section"> <label for="claimVoucher.cause" class="field prepend-icon"> <form:input path="claimVoucher.cause" class="gui-input" placeholder="事由..."/> <label for="claimVoucher.cause" class="field-icon"> <i class="fa fa-lock"></i> </label> </label> </div> <div class="section-divider mt20 mb40"> <span> 费用明细 </span> </div> <div class="section row" id="items"> <c:forEach items="${info.items}" varStatus="sta"> <div> <div class="col-md-3"> <label for="items[${sta.index}].item" class="field prepend-icon"> <form:hidden path="items[${sta.index}].id"/> <form:hidden path="items[${sta.index}].claimVoucherId"/> <form:select path="items[${sta.index}].item" cssClass="gui-input" placeholder="花销类型..." items="${items}"/> </label> </div> <div class="col-md-3"> <label for="items[${sta.index}].amount" class="field prepend-icon"> <form:input path="items[${sta.index}].amount" cssClass="gui-input money" placeholder="金额..." /> <label for="items[${sta.index}].amount" class="field-icon"> <i class="fa fa-lock"></i> </label> </label> </div> <div class="col-md-5"> <label for="items[${sta.index}].comment" class="field prepend-icon"> <form:input path="items[${sta.index}].comment" cssClass="gui-input" placeholder="备注..." /> <label for="items[${sta.index}].comment" class="field-icon"> <i class="fa fa-lock"></i> </label> </label> </div> <div class="col-md-1" style="text-align:right;"> <button type="button" class="button"> X </button> </div> </div> </c:forEach> </div> <div class="section row"> <div class="col-md-3"> <label for="totalMoney" class="field prepend-icon"> <form:input id="totalMoney" path="claimVoucher.totalAmount" cssClass="gui-input" placeholder="总金额..." readonly="true" /> <label for="totalMoney" class="field-icon"> <i class="fa fa-user"></i> </label> </label> </div> <div class="section" style="text-align:right;"> <div class="col-md-9"> <button type="button" class="button" id="addItemButton"> + </button> </div> </div> </div> <div class="panel-footer text-right"> <button type="submit" class="button"> 保存 </button> <button type="button" class="button" onclick="javascript:window.history.go(-1);"> 返回 </button> </div> </div> </form:form> </div> </div> </div> </section> <jsp:include page="bottom.jsp"/> <%--<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>--%> <%--<%@ page contentType="text/html;charset=UTF-8" language="java" %>--%> <%--<jsp:include page="top.jsp"/>--%> <%--<section id="content" class="table-layout animated fadeIn">--%> <%-- <div class="tray tray-center">--%> <%-- <div class="content-header">--%> <%-- <h2> 填写报销单 </h2>--%> <%-- <p class="lead"></p>--%> <%-- </div>--%> <%-- <div class="admin-form theme-primary mw1000 center-block" style="padding-bottom: 175px;">--%> <%-- <div class="panel heading-border">--%> <%-- <form:form id="admin-form" name="addForm" action="/claim_voucher/add" modelAttribute="info">--%> <%-- <div class="panel-body bg-light">--%> <%-- <div class="section-divider mt20 mb40">--%> <%-- <span> 基本信息 </span>--%> <%-- </div>--%> <%-- <div class="section">--%> <%-- <label for="claimVoucher.cause" class="field prepend-icon">--%> <%-- <form:input path="claimVoucher.cause" cssClass="gui-input" placeholder="事由..."/>--%> <%-- <label for="claimVoucher.cause" class="field-icon">--%> <%-- <i class="fa fa-lock"></i>--%> <%-- </label>--%> <%-- </label>--%> <%-- </div>--%> <%-- <div class="section-divider mt20 mb40">--%> <%-- <span> 费用明细 </span>--%> <%-- </div>--%> <%-- <div class="section row" id="items">--%> <%-- <div>--%> <%-- <div class="col-md-3">--%> <%-- <label for="items[0].item" class="field prepend-icon">--%> <%-- <form:select path="items[0].item" cssClass="gui-input" placeholder="花销类型..." items="${items}"/>--%> <%-- </label>--%> <%-- </div>--%> <%-- <div class="col-md-3">--%> <%-- <label for="items[0].amount" class="field prepend-icon">--%> <%-- <form:input path="items[0].amount" cssClass="gui-input money" placeholder="金额..."/>--%> <%-- <label for="items[0].amount" class="field-icon">--%> <%-- <i class="fa fa-lock"></i>--%> <%-- </label>--%> <%-- </label>--%> <%-- </div>--%> <%-- <div class="col-md-5">--%> <%-- <label for="items[0].comment" class="field prepend-icon">--%> <%-- <form:input path="items[0].comment" cssClass="gui-input" placeholder="备注..." />--%> <%-- <label for="items[0].comment" class="field-icon">--%> <%-- <i class="fa fa-lock"></i>--%> <%-- </label>--%> <%-- </label>--%> <%-- </div>--%> <%-- <div class="col-md-1" style="text-align:right;">--%> <%-- <button type="button" class="button"> X </button>--%> <%-- </div>--%> <%-- </div>--%> <%-- </div>--%> <%-- <div class="section row">--%> <%-- <div class="col-md-3">--%> <%-- <label for="totalMoney" class="field prepend-icon">--%> <%-- <form:input id="totalMoney" path="claimVoucher.totalAmount" cssClass="gui-input" placeholder="总金额..." readonly="true"/>--%> <%-- <label for="totalMoney" class="field-icon">--%> <%-- <i class="fa fa-user"></i>--%> <%-- </label>--%> <%-- </label>--%> <%-- </div>--%> <%-- <div class="section" style="text-align:right;">--%> <%-- <div class="col-md-9">--%> <%-- <button type="button" class="button" id="addItemButton"> + </button>--%> <%-- </div>--%> <%-- </div>--%> <%-- </div>--%> <%-- <div class="panel-footer text-right">--%> <%-- <button type="submit" class="button"> 保存 </button>--%> <%-- <button type="button" class="button" onclick="javascript:window.history.go(-1);"> 返回 </button>--%> <%-- </div>--%> <%-- </div>--%> <%-- </form:form>--%> <%-- </div>--%> <%-- </div>--%> <%-- </div>--%> <%--</section>--%> <%--<jsp:include page="bottom.jsp"/>--%>
22
收起
正在回答 回答被采纳积分+1
2回答
4. SSM到Spring Boot入门与综合实战
- 参与学习 人
- 提交作业 323 份
- 解答问题 8263 个
本阶段将带你学习主流框架SSM,以及SpringBoot ,打通成为Java工程师的最后一公里!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星