본문 바로가기
Thymeleaf

You don't need to put the layout:fragment/data-layout-fragment attribute into the <head> section - the decoration process will automatically copy the <head> section of your content templates into your layout page.

by Soono991 2023. 4. 23.

타임리프에서 레이아웃 기능을 사용하던 도중 아래와 같은 warning이 출력된 적이 있습니다.

 

n.n.u.t.l.f.FragmentProcessor [75] 
- You don't need to put the layout:fragment/data-layout-fragment attribute 
into the <head> section - the decoration process will automatically copy the 
<head> section of your content templates into your layout page.

 

warning을 읽어보면 레이아웃에서 <head> 태그 안에서 fragment를 사용할 필요가 없다고 합니다.

레이아웃을 사용하려는 페이지에서 <head> 태그를 만들고 그 안에 내용을 추가하면 레이아웃이 자동으로 해당 내용을 병합한다고 합니다.

 

해당 warning이 발생한 상황은 페이지마다 사용할 정적 리소스(css, js)등이 상이하여 레이아웃에서 <head> 안에 fragment를 만들고 각 페이지에서 fragment에 사용할 정적 리소스(css, js)등을 추가하려고 했습니다.

 

 

하지만 warning에서 언급한 대로 fragment를 만들 필요 없이 각 페이지에서 <head>를 작성하면 레이아웃에서 병합을 해준다고 하기 때문에 아래와 같이 사용하면 됩니다.

 

 

'Thymeleaf' 카테고리의 다른 글

Thymeleaf 3.1 release note  (0) 2023.04.16

댓글