개발 무지렁이

[Thymeleaf] 오류 메세지 공통 템플릿 본문

Frontend/HTML

[Thymeleaf] 오류 메세지 공통 템플릿

Gaejirang-e 2022. 11. 28. 17:05

[form_errors.html]

<html lang="ko"
      xmlns:th="http://thymeleaf.org"
>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
      integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

<div th:fragment="formErrorsFragment" class="alert alert-danger" role="alert" th:if="${#fields.hasAnyErrors()}">
    <div th:each="err : ${#fields.allErrors()}" th:text="${err}" />
</div>
</html>

[공통템플릿을 적용하는 템플릿.html]

<div th:replace="form_errors :: formErrorsFragment"></div>

'Frontend > HTML' 카테고리의 다른 글

[Thymeleaf] Thymeleaf의 템플릿 상속  (0) 2022.11.27
Comments