🤯TIL/Spring

[게시판 만들기 - 3 ] 게시판 읽기

Dorothy_YANG 2022. 12. 6. 19:22
728x90

목 차

6. 게시판 읽기
     - 작업1> Controller : 읽기 매핑주소 및 메서드 작업 
     - 작업2> Mapper interface와 Mapper XML작업 
                    - Mapper Interface : 메서드 작업
                    - Mapper XML : SQL 구문작업
     - 작업3> Service 작업 
                   -Service인터페이스 : 추상 메서드 작업
                   -Servicelmpl(구현) 클래스 : 메서드 구현 
     -작업4> Controller : Service의 메서드 호출
     -작업5> VIEW 처리 : get.jsp 파일 생성


작업1> Controller : 리스트 매핑주소 및 메서드 작업 



작업2> Mapper interface와 Mapper XML작업 

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


작업3> Service 작업 

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



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

 


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

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
 	
<script>

    $(document).ready(function(){
        $("#btnModify").click(function(){
            let bno = $(this).data("bno");
            location.href = "/board/modify?bno=" + bno;
        });

        $("#btnRemove").click(function(){

            if(!confirm("삭제 하시겠습니까?")) return;

            let bno = $(this).data("bno");
            location.href = "/board/remove?bno=" + bno;
        });
    });
</script>

 

      <!--------------------------
        | 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">Dorothy's Board 조회</h3>
			</div>
		
				<div class = "box-body">
					<div class = "form-group">
						<label for = "title">Bno</label>
						<input type = "text" class = "form-control" value = "${board.bno}" readonly>
					</div>
				<div class = "form-group">
					<label for = "title">Title</label>
					<input type="text" class="form-control" value="${board.title}" readonly>
				</div>
				<div class="form-group">
					<label for="content">Content</label>
					<%-- <input type="text" class="form-control" value="${board.content}" readonly>--%>
					<c:out value="${board.content}" />
				</div>
				<div class="form-group">
					<label for="writer">Writer</label>
					<input type="text" class="form-control" value="${board.writer}" readonly>
				</div>
							
				<div class="form-group">
					<label for="writer">Regdate</label>
					<input type="text" class="form-control" value="<fmt:formatDate value="${board.regdate}" pattern="yyyy-MM-dd hh:mm"/>" readonly>
				</div>
							
				<div class="form-group">
					<label for="writer">Updatedate</label>
					<input type="text" class="form-control" value="<fmt:formatDate value="${board.regdate}" pattern="yyyy-MM-dd hh:mm"/>" readonly>
				</div>
							
					<button type="button" class="btn btn-primary" id="btnModify" data-bno="${board.bno}">Modify</button>
					<button type="button" class="btn btn-primary" id="btnRemove" data-bno="${board.bno}">Remove</button>
					<button type="button" class="btn btn-primary" id="btnList">List</button>
					</div>
				</div>
			</div>
		</div>
    </section>

 

 

ex) 실행 화면

 

728x90