[Thymeleaf] JavaScript에서 Thymeleaf 사용 방법

반응형
반응형

 

 

Thymeleaf, JavaScript에서 Thymeleaf 사용

 

 

 

 

 

  JavaScript에서 Thymeleaf 사용 방법

<script th:inline="javascript">

</script>

 JavaScript에서 Thymeleaf를 사용하기 위해서는 th:inline="javascript"를 script에 추가하기만 하면 된다.

 

일반적인 script에서는 thymeleaf를 사용할 수 없으며, 오직 th:inline이 선언된 script에서만 사용할 수 있다.

 

그 뒤로는 [[]] 대괄호를 통해 thymeleaf를 보호한다.

 

var test = [[${session.test.tt}]];

thymeleaf에서 session을 불러오는 방법이다. javascript에서는 대괄호로 보호한 대상만 값을 온전히 불러올 수 있다.

반응형

'Web > Thymeleaf' 카테고리의 다른 글

[Thymeleaf] NULL 구분하기  (0) 2022.04.07
[Thymeleaf] template 기능, layout  (0) 2022.03.23
[Thymeleaf] template 기능 - replace  (0) 2022.03.23
[Thymeleaf] for 사용하기  (1) 2022.03.08
[Thymeleaf] if - else 사용하기  (0) 2022.03.08

댓글

Designed by JB FACTORY