更新之后,创建时间不见了,问题出现在哪里?老师在视频里把设置创建时间给去掉了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 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); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | //去更新 @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" ; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | <%@ 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积分~
来为老师/同学的回答评分吧