🤯TIL/Spring

[게시판 만들기 - 4 ] 게시판 수정하기 / 삭제하기

Dorothy_YANG 2022. 12. 9. 17:42
728x90

목 차

7. 게시판 수정 / 삭제
     - 작업1> Controller : 매핑주소 및 메서드 작업 
     - 작업2> Mapper interface와 Mapper XML작업 
                    - Mapper Interface : 메서드 작업
                    - Mapper XML : SQL 구문작업
     - 작업3> Service 작업 
                   -Service인터페이스 : 추상 메서드 작업
                   -Servicelmpl(구현) 클래스 : 메서드 구현 
     -작업4> Controller : Service의 메서드 호출
     [-작업5> VIEW 처리 : modify.jsp 파일 생성] ➡ remove에선 생략

 


< 게시글 수정하기 >

작업1> Controller : 수정 매핑주소 및 메서드 작업 


작업2> Mapper interface와 Mapper XML작업 

               - Mapper Interface : 메서드 작업
               - Mapper XML : SQL 구문작업


작업3> Service 작업 

               -Service인터페이스 : 추상 메서드 작업
               -Servicelmpl(구현) 클래스 : 메서드 구현 


작업4> Controller : Service의 메서드 호출 

  • get 주소에 modify 주소 추가


작업5> VIEW 처리 : list.jsp 파일 생성

(1) 추가

       <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>      

 

(2) 

<!--------------------------
        | Your Page Content Here |
        -------------------------->

<div class="row">
    <div class="col-md-12">
        <div class="box box-primary">
            <div class="box-header with-border">
            <h3 class="box-title">게시판 글수정</h3>
            </div>


            <form role="form" method="post" action="modify">
                <div class="box-body">
                    <div class="form-group">
                    <label for="bno">Bno</label>
                    <input type="text" class="form-control" id="bno" name="bno" value="<c:out value="${board.bno }" />" readonly>
                    </div>
                    <div class="form-group">
                    <label for="title">Title</label>
                    <input type="text" class="form-control" id="title" name="title" placeholder="제목 입력" value="<c:out value="${board.title }" />">
                    </div>
                    <div class="form-group">
                    <label for="content">Content</label>
                    <textarea class="form-control" aria-label="With textarea" name="content"><c:out value="${board.content }" /></textarea>
                    </div>

                    <div class="form-group">
                    <label for="writer">Writer</label>
                    <input type="text" class="form-control" id="writer" name="writer"  placeholder="작성자 입력" value="<c:out value="${board.writer }" />" readonly>
                    </div>

                </div>

                <div class="box-footer">
                    <button type="submit" class="btn btn-primary">Save</button>
                </div>
            </form>
        </div>
    </div>
</div>

 

 

ex) 실행화면

팝업창 메세지는 list.jsp에 들어간다.

 

 


< 게시글 삭제하기 >

작업1> Controller : 삭제 매핑주소 및 메서드 작업 


작업2> Mapper interface와 Mapper XML작업 

               - Mapper Interface : 메서드 작업
               - Mapper XML : SQL 구문작업


작업3> Service 작업 

               -Service인터페이스 : 추상 메서드 작업
               -Servicelmpl(구현) 클래스 : 메서드 구현 


작업4> Controller : Service의 메서드 호출 

 

 

 

ex) 실행 화면

728x90