STUDY ROOM
[Thymeleaf#1] 정의 본문
Thymeleaf란?
- 자바 템플릿 엔진
- Html 기반으로, 확장자도 Html
- JSP 태그 라이브러리는 브라우저가 해석할 수 없는 반면, 타임리프는 브라우저가 문제없이 문법을 해석할 수 있다. (디자이너와 협업에 유용함)
- '#': 타임리프에서 메세지를 나타내는 키워드
- home.welcome 키에 해당하는 값을 스프링부트에서 설정.
- '@' 링크를 나타내는 타임리프의 키워드
- th:classappend : 조건에 따라 클래스를 동적으로 추가하여 사용함
- th:href URL parameters (as you can see in orderId=${o.id})
Thymeleaf와 JPA의 차이점
: Thymeleaf는 HTML, XML, JavaScript, CSS 및 일반 텍스트를 처리 할 수 있는 웹 및 독립형 환경에서 사용할 수 있는 Java 템플릿 엔진. Thymeleaf는 html파일을 가져와서 파싱해서 분석후 정해진 위치에 데이터를 치환해서 웹 페이지를 생성함.
JSP는 서블릿으로 변환되어 실행. JSP 내에서 자바 코드 사용 가능(사용하지 못하도록 설정할 수 있음). Thymeleaf는 자바코드를 사용할 수 없고, jsp에서 처럼 커스텀 태그와 같은 기능도 없다.
출처: https://offbyone.tistory.com/410 [쉬고 싶은 개발자]
튜토리얼
<table>
<thead>
<tr>
<th th:text="#{msgs.headers.name}">Name</th>
<th th:text="#{msgs.headers.price}">Price</th>
</tr>
</thead>
<tbody>
<tr th:each="prod: ${allProducts}">
<td th:text="${prod.name}">Oranges</td>
<td th:text="${#numbers.formatDecimal(prod.price, 1, 2)}">0.99</td>
</tr>
</tbody>
</table>
'Spring' 카테고리의 다른 글
[JPA#2] JPA 매핑 (0) | 2020.12.28 |
---|---|
[JPA#1] JPA 정의 (0) | 2020.12.02 |
스프링 기본(2) -AOP와 트랜잭션 (0) | 2019.12.26 |
스프링 기본(1) -프레임워크란? (0) | 2019.12.08 |
Comments