[점프투스프링부트 2-14 템플릿 상속] 템플릿 상속이 되지 않습니다.

안녕하세요?
점프투스프링이라는 좋은 교재를 만나서 무척 기쁘게 배우고 있습니다.

질문드립니다.
quetion_list.html 과 quetion_detail.html 에 layout.html 이 적용되지 않는 것 같습니다.
두 페이지의 소스를 보면

<html layout:decorate="~{layout}">

와 같이 태그에 속성이 그대로 나오고 있습니다.

무엇이 문제인지 몰라서 이곳에 질문합니다.

// layout.html
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link rel="stylesheet" type="text/css" th:href="@{/bootstrap.min.css}">

    <link rel="stylesheet" type="text/css" th:href="@{/style.css}">
    <title>Hello, SBB!</title>
</head>
<body>
<th:block layout:fragment="content"></th:block>
</body>
</html>
// question_list.html
<!DOCTYPE html>
<html layout:decorate="~{layout}">
<div layout:fragment="content" class="container my-3">
    <table class="table">
        <thead class="table-dark">
            <tr>
                <th>번호</th>
                <th>제목</th>
                <th>작성일시</th>
            </tr>
        </thead>
        <tbody>
            <tr th:each="question, loop : ${questionList}">
                <td th:test="${loop.count}"></td>
                <td>
                    <a th:href="@{|/question/detail/${question.id}|}" th:text="${question.subject}"></a>
                </td>
                <td th:text="${#temporals.format(question.createDate, 'yyyy-MM-dd HH:mm')}"></td>
            </tr>
        </tbody>
    </table>
    <a th:href="@{/question/create}" class="btn btn-primary">질문 등록하기</a>
</div>
</html>

// question_detail.html
<!DOCTYPE html>
<html layout:decorate="~{layout}">
<div layout:fragment="content" class="container my-3">

    <h2 class="border-bottom py-2" th:text="${question.subject}"></h2>
    <div class="card my-3">
        <div class="card-body">
            <div class="card-text" style="white-space: pre-line;" th:text="${question.content}"></div>
            <div class="d-flex justify-content-end">
                <div class="badge bg-light text-dark p-2 text-start">
                    <div th:text="${#temporals.format(question.createDate, 'yyyy-MM-dd HH:mm')}"></div>
                </div>
            </div>
        </div>
    </div>

    <h5 class="border-bottom my-3 py-2" th:text="|${#lists.size(question.answerList)}개의 답변이 있습니다.|"></h5>

    <div class="card my-3" th:each="answer : ${question.answerList}">
        <div class="card-body">
            <div class="card-text" style="white-space: pre-line;" th:text="${answer.content}"></div>
            <div class="d-flex justify-content-end">
                <div class="badge bg-light text-dark p-2 text-start">
                    <div th:text="${#temporals.format(answer.createDate, 'yyyy-MM-dd HH:mm')}"></div>
                </div>
            </div>
        </div>
    </div>

    <form th:action="@{|/answer/create/${question.id}|}" method="post" class="my-3">
        <textarea name="content" id="content" rows="10" class="form-control"></textarea>
        <input type="submit" value="답변등록" class="btn btn-primary my-2">
    </form>
</div>
</html>
// build.gradle
plugins {
    id 'org.springframework.boot' version '2.7.2'
    id 'io.spring.dependency-management' version '1.0.12.RELEASE'
    id 'java'
}

group = 'com.mysite'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    runtimeOnly 'com.h2database:h2'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialact'
}

tasks.named('test') {
    useJUnitPlatform()
}

meohin.meo 375

M 2022년 9월 6일 2:52 오후

목록으로
1개의 답변이 있습니다. 1 / 1 Page

자문자답
그레이들 종속성 세팅에서 오타가 있어서 발생한 문제였습니다.
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialact'

implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'
로 수정하고 문제를 해결했습니다.

meohin.meo

2022년 9월 6일 3:47 오후