Notice
Recent Posts
Recent Comments
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Archives
Today
Total
관리 메뉴

충분히 쌓여가는

thymeleaf를 사용하여 레이아웃 적용 본문

Spring/project

thymeleaf를 사용하여 레이아웃 적용

빌드이너프 2023. 12. 24. 21:11

https://www.thymeleaf.org/

 

Thymeleaf

Integrations galore Eclipse, IntelliJ IDEA, Spring, Play, even the up-and-coming Model-View-Controller API for Java EE 8. Write Thymeleaf in your favourite tools, using your favourite web-development framework. Check out our Ecosystem to see more integrati

www.thymeleaf.org

 

(thymeleaf에 Docs에서 Read online 클릭 후 fragment 찾아보기)

src>main>resources>templates에 fragments 디렉터리 생성>layout.html 생성 후 일단 복붙

<!DOCTYPE html>

<html xmlns:th="http://www.thymeleaf.org">

  <body>
  
    <div th:fragment="header">
      <p>header 영역입니다</p>
    </div>
  
  </body>
  
</html>

 

 

thymeleaf 문법의 replace 사용

src>main>resources>templates>index.html(localhost:8080)

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Index Page</title>
    <link rel="stylesheet" href="index.css">
</head>
<body>
<div th:replace="fragments/layout :: header"></div>
<div>
    <h1>index page</h1>
</div>
</body>
</html>

'Spring > project' 카테고리의 다른 글

글 작성 view 구현  (0) 2023.12.25
게시판 기능(CRUD)  (0) 2023.12.25
스프링 시큐리티를 사용한 인증, 인가  (0) 2023.12.25
게시판 리스트 페이지 생성  (0) 2023.12.24
프로젝트 생성 및 기본 index 페이지  (0) 2023.12.24