spring boot 웹앱의 footer를 fragment로 분리하기
스프링 부트에서 헤더와 푸터를 fragment로 분리하는 방법에 대한 코드 조각입니다.
전체 소스는 다음 링크를 참고하세요.
https://github.com/VisualAcademy/JavaCampus
***views/shared/fragments/_footer.html***
```HTML
<html lagn="ko" xmlns:th="http://www.thymeleaf.org">
<!-- Footer -->
<footer class="py-5 bg-dark mt-auto" th:fragment="footer">
<div class="container">
<p class="m-0 text-center text-white">Copyright © JavaCampus 2022 All rights reserved.</p>
</div>
<div class="container">
<p class="m-0 text-center text-white">
<a href="https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/">
Spring Boot Reference Documentation
</a>
</p>
</div>
<div class="container">
<p class="m-0 text-center text-white">
<a href="https://startbootstrap.com/" class="text-white small">
Bootstrap Template by Start Bootstrap
</a>
</p>
</div>
<!-- /.container -->
</footer>
</html>
```
***views/shared/_layout.html***
```HTML
<!DOCTYPE html>
<html lang="en"
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
</head>
<body class="d-flex flex-column min-vh-100">
<div layout:fragment="content">
<p>내용 들어오는 곳...</p>
</div>
<footer th:replace="views/shared/fragments/_footer :: footer">
푸터 들어오는 곳
</footer>
</body>
</html>
```
Comments
Comments are closed