My footsteps

구멍가게코딩단 '코드로 배우는 스프링부트 웹프로젝트' / 4 본문

Develop/곤부📙

구멍가게코딩단 '코드로 배우는 스프링부트 웹프로젝트' / 4

밀김 2023. 10. 27. 15:48
728x90

 

 

 

 

 

 

 

방명록(register) HTML

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
    <th:block th:replace="~{/layout/basic :: setContent(~{this::content})}">
        <th:block th:fragment="content">
            <h1 class="mt-4">방명록 페이지</h1>
            <form th:action="@{/guestbook/register}" th:method="post">

                <div class="form-group">
                    <label>제목</label>
                    <input type="text" class="form-control" name="title" placeholder="제목을 입력하세요">
                </div>

                <div class="form-group">
                    <label>내용</label>
                    <textarea class="form-control" name="content" rows="5"></textarea>
                </div>

                <div class="form-group">
                    <label>작성자</label>
                    <input type="text" class="form-control" name="writer" placeholder="작성자를 입력하세요">
                </div>

                <button type="submit" class="btn btn-primary">작성</button>
            </form>
        </th:block>
    </th:block>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>

 

 

 

<button type="button" class="close" data-dismiss="modal" aria-label="Close">

data-dismiss : 모달을 닫는데 사용됨

aria-label : 버튼에 글자 나타내는거

※부트스트랩을 사용하지 않고도 쓸수있음 그냥 HTML 내장속성임

 

 

 

<span aria-hidden="true">&times;</span>

aria-hidden을 사용하면 사용자에게 보이지 않게 숨기겠다는 내용이다. 

글고 &times; 는 문자 X 를 의미함. 걍 닫기 나타낸거임

 

 

 

@Override
public GuestbookDTO read(Long gno) {
    Optional<Guestbook> result = repository.findById(gno);
    return result.isPresent()? entityToDto(result.get()): null;
    //삼항연산자 이용
    // result.isPresent()가 참이면 entityToDto(result.get())가 반환되고
    // result.isPresent()가 거짓이면 null이 반환되고

}

 

 

 

RequestDTO 는 데이터 전송 객체이다

 

728x90