티스토리 뷰

Spring

SPRING 수정 기능 순서 흐름

piern 2018. 12. 14. 04:34

1. BoardDAO.java : 인터페이스

public void update(BoardVO vo) throws Exception;


2. mapper

<update id="update" parameterType="hashmap">

UPDATE tbl_board set title =#{title}, content =#{content}

WHERE bno = #{bno}

</update>


3. BoardDAOImpl.java

@Override

  public void update(BoardVO vo) throws Exception {

    session.update(namespace + ".update", vo);

  }


4. BoardService.java : 인터페이스

public void modify(BoardVO board) throws Exception;


5. BoardServiceImpl.java

 @Override

  public void modify(BoardVO board) throws Exception {

    dao.update(board);

  }


6. BoardController.java

@RequestMapping(value = "/modify", method = RequestMethod.GET)

  public void modifyGET(int bno, Model model) throws Exception {


    model.addAttribute(service.read(bno));

  }


7. modify.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8"%>


<%@include file="../include/header.jsp"%>


<!-- Main content -->

<section class="content">

<div class="row">

<!-- left column -->

<div class="col-md-12">

<!-- general form elements -->

<div class="box box-primary">

<div class="box-header">

<h3 class="box-title">READ BOARD</h3>

</div>

<!-- /.box-header -->


<form role="form" method="post">


<div class="box-body">


<div class="form-group">

<label for="exampleInputEmail1">BNO</label> <input type="text"

name='bno' class="form-control" value="${boardVO.bno}"

readonly="readonly">

</div>


<div class="form-group">

<label for="exampleInputEmail1">Title</label> <input type="text"

name='title' class="form-control" value="${boardVO.title}">

</div>

<div class="form-group">

<label for="exampleInputPassword1">Content</label>

<textarea class="form-control" name="content" rows="3">${boardVO.content}</textarea>

</div>

<div class="form-group">

<label for="exampleInputEmail1">Writer</label> <input type="text"

name="writer" class="form-control" value="${boardVO.writer}">

</div>

</div>

<!-- /.box-body -->

</form>



<div class="box-footer">

<button type="submit" class="btn btn-primary">SAVE</button>

<button type="submit" class="btn btn-warning">CANCEL</button>

</div>


<script>

$(document).ready(function() {


var formObj = $("form[role='form']");


console.log(formObj);


$(".btn-warning").on("click", function() {

self.location = "/board/listAll";

});


$(".btn-primary").on("click", function() {

formObj.submit();

});


});

</script>


</div>

<!-- /.box -->

</div>

<!--/.col (left) -->


</div>

<!-- /.row -->

</section>

<!-- /.content -->

</div>

<!-- /.content-wrapper -->


<%@include file="../include/footer.jsp"%>



'Spring' 카테고리의 다른 글

링크(image,css,js) 경로 설정  (0) 2020.02.08
Spring Error Page (에러 페이지) 설정  (0) 2019.06.26
SPRING 삭제 기능 순서 흐름  (0) 2018.12.14
SPRING 조회 기능 순서 흐름  (0) 2018.12.14
SPRING 리스트 기능 순서 흐름  (0) 2018.12.14
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/12   »
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
글 보관함