프로젝트

가전제품 대여 웹사이트 (세숫대여) - 게시판 댓글 조회 기능 구현

sejin2 2023. 9. 29. 20:26

댓글을 작성했으면 작성한 댓글을 조회할 수 있어야 한다.  사용자가 댓글 리스트를 볼 수 있는 화면을 만들고, DB에 저장된 값을 불러오도록 한다.    

freeboarddetail.jsp

<!-- 자유게시글 댓글 리스트 보기 기능 구현 시작-->
	<table id="review-list" class="table align-items-center table-flush">
	    <thead class="thead-light">
	        <tr style="text-align:center">
	            <th scope="col" style="width: 50px">댓글번호</th> 
	            <th scope="col" style="width: 300px">댓글내용</th>
	             <th scope="col" style="width: 150px">댓글작성자</th>
	            <th scope="col" style="width: 150px">댓글작성일자</th>
	            <th scope="col" style="width: 150px">댓글수정삭제</th>
	        </tr>
	    </thead>
    	<tbody>
        <c:forEach var="freeBoardReview" items="${freeBoard.freeBoardReviewList}">
            <tr style="text-align:center">
                <td style="width: 50px">${freeBoardReview.freeBoardReplyNo}</td>
				<td scope="col" style="width:200px"> <input type="hidden" name="memberNo" value="${ loginuser.memberId }"> 
                <td style="width: 150px">
                    <fmt:formatDate value="${freeBoardReview.replyCreateDate}" pattern="yyyy-MM-dd HH:mm" />
                </td>
                <td>
                    <a class="btn btn-sm btn-primary edit-reply" data-reply-no="${freeBoardReview.freeBoardReplyNo}" href="javascript:void(0)" style="color: white">댓글수정하기</a>
                    <a class="btn btn-sm btn-primary delete-reply" data-reply-no="${freeBoardReview.freeBoardReplyNo}" href="javascript:void(0)" style="color: white">댓글삭제하기</a>
                </td>
            </tr>
            <tr>
                <td colspan="5">
                    <div id="reply-edit-area-${freeBoardReview.freeBoardReplyNo}" style="display: none">
                        ${sessionScope.loginuser.memberId} &nbsp;&nbsp; [댓글 수정 시간 : ${freeBoardReview.replyCreateDate}] <br />
                        <br />
                        <form action="edit-reply" method="post" style="width: 105%; resize: none;">
                            <input type="hidden" name="freeBoardReplyNo" value="${freeBoardReview.freeBoardReplyNo}" />
                            <input type="hidden" name="freeBoardNo" value="${freeBoard.freeBoardNo}" />
                            <input type="hidden" name="pageNo" value="${pageNo}" />
                            <textarea name="replyContent" style="width: 70%; resize: none; border-radius: 80px" rows="2" maxlength="200" >${freeBoardReview.replyContent}</textarea>
                            <br />
                            <div class="btn btn-sm btn-primary">
                                <a class="update-reply" data-reply-no="${freeBoardReview.freeBoardReplyNo}" href="javascript:void(0)" style="color: white">수정완료</a>
                            </div>
                            <div class="btn btn-sm btn-primary">
                                <a class="cancel-edit-reply" data-reply-no="${freeBoardReview.freeBoardReplyNo}" href="javascript:void(0)" style="color: white">수정취소</a>
                            </div>
                        </form>
                    </div>
                </td>
            </tr> 
    </tbody>
</table>

 

그러면 DB에 저장된 댓글들이 나타난다.

하 근데 여기서 또 댓글 작성시간이 이상하게 들어온다. . 도대체 뭐가 문제인지 알 수 없다.