본문 바로가기
IT/Java

[Error] Deprecated unwrapped fragment expression "~/~" found in template ~/~

by 성준하이 2024. 10. 11.
반응형

Spring 과 thymeleaf 를 사용하면서 아래와 같은 에러를 만났다.

 

Deprecated unwrapped fragment expression "~/~" found in template ~/~, line 9, col 7.
Please use the complete syntax of fragment expressions instead ("~{~/~}"). The old, unwrapped syntax for fragment expressions will be removed in future versions of Thymeleaf.

굉장히 길어보이는데 주요 문구 몇개만 확인하면 내용은 쉽게 이해 된다.

 

html 내의 기존 구문은 아래와 같았다.

<div th:replace="test/test_modal :: fragment"></div>

 

당연히 test 라는 폴더 내에 test_modal.html 이라는 파일은 존재하고 yml 파일에 suffix, prefix 등 모두 지정하여서 올바르게 동작할 코드이다.

 

근데 에러에서 친절하게 해결법이 나와있다.

 

기존 코드를 아래와 같이 변경해주면 해결된다.

<div th:replace="~{test/test_modal :: fragment}"></div>

 

Thymeleaf 3.0 부터는 fragment 를 포함하는 구문이 더욱 엄격해져서 위와 같이 명시하도록 변경되었다고 한다.

참고로 Thymeleaf 관련해서는 아래 참고 포스팅 참고 바란다.


참고 포스팅

https://thenicesj.tistory.com/464

 

Tymeleaf 란?

'템플릿 엔진'의 일종. html 태그에 속성을 추가해 페이지에 동적으로 값을 추가하거나 처리할 수 있다. 템플릿 엔진이란? 지정된 템플릿 양식과 데이터가 합쳐져 html 문서를 출력하는 소프트웨어

thenicesj.tistory.com

 

반응형

'IT > Java' 카테고리의 다른 글

Generic Type 2  (16) 2024.10.14
Generic Type  (10) 2024.10.13
Spring Banner 만들기  (13) 2024.10.09
Spring 내부에서 요청 파라미터 처리 과정  (12) 2024.10.06
[Error] Invalid character found in method name  (12) 2024.10.05

댓글