<!--정보 수정 -->
<update id="update" parameterType="cusVO" >
UPDATE CUS SET CUS_NM=#{cusNm}, PNE=#{pne}, ADDR=#{addr}
WHERE CUS_NUM=#{cusNum}
</update>
//정보 수정
public int update(CusVO cusNm);
//수정하기
@Override
public int update(CusVO cusVo) {
return this.cusMapper.update(cusVo);
}
//수정하기
public int update(CusVO cusVO);
///cus/detail?cusNum=1
//고객 상세 정보
@GetMapping("/detail")
public String detail(Model model,
@RequestParam String cusNum) {
model.addAttribute("pageHeader", UserUtil.getPageHeader("Customer", "고객 상세"));
List<CusVO> list = this.cusService.detail(cusNum);
logger.info("상세정보: "+list);
//다중 이미지를 모두 보이고 싶을때...
//CusVO cusVO = this.cusService.detail(cusNum);
// if(cusVO==null) { //없으면
// return "cus/list"
// }else {//있으면
// return "cus/detail";
// }
for (CusVO cusVO : list) {
model.addAttribute("cusVO", cusVO);
}
//forwarding
return "cus/detail";
}
@PostMapping("/detail")
public String update(@ModelAttribute CusVO cusVO) {
logger.info("cusVO : " + cusVO);
int update = cusService.update(cusVO);
if(update<1) {//수정 실패
return "cus/detail";
}
//forwarding
return "redirect:/cus/detail?cusNum="+cusVO.getCusNum();
}
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
폼테그를 사용하기 위해 작성 해야함!
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
시큐리티를 사용하기 위해 작성해야함!
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<div class="color-switcher-toggle animated pulse infinite">
<i class="material-icons">settings</i>
</div>
<div class="main-content-container container-fluid px-4">
<!-- Main Navbar -->
<!-- / .main-navbar -->
<!--
업데이트 성공시 뜨는 문
<div class="alert alert-success alert-dismissible fade show mb-0" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<i class="fa fa-check mx-2"></i>
<strong>Success!</strong> Your profile has been updated! </div>
-->
<div class="main-content-container container-fluid px-4">
<!-- Default Light Table -->
<div class="row">
<div class="col-lg-4">
<div class="card card-small mb-4 pt-3">
<div class="card-header border-bottom text-center">
<div class="mb-3 mx-auto">
<c:forEach var="attachFilesVO" items="${cusVO.attachFilesVO}">
<img class="rounded-circle" src="${attachFilesVO.uploadFileName}" alt="User Avatar" width="110">
</c:forEach>
</div>
<h4 class="mb-0">${cusVO.cusNm}</h4>
<button type="button" class="mb-2 btn btn-sm btn-pill btn-outline-primary mr-2">
<i class="material-icons mr-1">person_add</i>Follow</button>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item p-4">
<strong class="text-muted d-block mb-2">Description</strong>
<span>회원 페이지의 상세보기 페이지입니다.</span>
</li>
</ul>
</div>
</div>
<div class="col-lg-8">
<div class="card card-small mb-4">
<div class="card-header border-bottom">
<h6 class="m-0"><strong>고객 상세 정보</strong></h6>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item p-3">
<div class="row">
<div class="col">
<form:form modelAttribute="cusVO" method="post"
action="/cus/detail" >
<div class="form-row">
<div class="form-group col-md-6">
<label for="feFirstName">고객번호</label>
<form:input type="text" class="form-control" path="cusNum" placeholder="" value="${cusVO.cusNum}"/> </div>
<div class="form-group col-md-6">
<label for="feLastName">고객명</label>
<form:input type="text" class="form-control fom2" path="cusNm" placeholder="" value="${cusVO.cusNm}"/> </div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="feEmailAddress">연락처</label>
<form:input type="text" class="form-control fom2" path="pne" placeholder="" value="${cusVO.pne}"/> </div>
</div>
<div class="form-group">
<label for="feInputAddress">Address</label>
<form:input type="text" class="form-control fom2" path="addr" value="${cusVO.addr}"/> </div>
<div class="form-row">
</div>
<div id="div1">
<button id="but1" type="button" class="btn btn-accent" onclick="btnshow()">정보 수정하기</button>
<a class="btn btn-warning" href="/cus/list">목록으로</a>
<button type="button" class="btn btn-secondary"
onclick="makePdf()">PDF다운로드</button>
</div>
<div id="div2" >
<button type="submit" class="btn btn-accent" >확인</button>
<a class="btn btn-warning" href="/cus/list">취소</a>
</div>
이걸 써야 시큐리티를 풀어도 에러가 나지 않음
<sec:csrfInput/>
</form:form>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<!-- End Default Light Table -->
</div>
</div>