사용자 도구

사이트 도구


wiki:thymeleaf

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

다음 판
이전 판
wiki:thymeleaf [2020/07/10 13:54]
hylee 만듦
wiki:thymeleaf [2023/03/29 10:17] (현재)
dhan
줄 8: 줄 8:
 <WRAP clear/> <WRAP clear/>
  
-===== Thymeleaf =====+===== Intro ===== 
 +==== Thymeleaf란? ==== 
 +  * Thymeleaf는 스프링 부트가 자동 설정을 지원하는  웹 템플릿 엔진입니다. \\  
 + 
 +  * HTML문서에 HTML5 문법으로 서버쪽 로직을 수행하고 적용시킬 수 있습니다. \\ 
 + 
 +  * HTML 디자인에 전혀 영향을 미치지 않고 웹 템플릿 엔진을 통해 HTML을 생성할 수 있습니다. \\ 
 + 
 +  * 독자적으로 HTML을 생성하기 때문에 테스트 시 렌더링 결과를 확인하기 좋습니다. 
 + 
 +  * Spring 에서 jsp대신 Thymeleaf를 선호한다. 
 \\ \\
 +
 +===== Operator(연산자) =====
 +==== 세이프 네비게이션 연산자 [?.] ====
 +<code java>
 +Person person = null; 
 +person?.name; // name은 Person 클래스의 맴버 변수
 +System.out.println(name); // null - NullPointerException을 던지지 않는다!!!
 +</code>
 +==== 엘비스 연산자[?:] ====
 +<code java>
 +String name = null;
 +name ? : "기본값";
 +System.out.println(name); // 기본값
 +</code>
 +==== if - else 사용법 =====
 +<code jsp>
 +  <TAG th:if="조건문" ></TAG>
 +  <TAG th:unless ></TAG>
 +</code>
 +> 조건문은 무조건 동일하여 적어주어야 정상적으로 동작
 +
 +  * [[https://solbel.tistory.com/1406|[thymeleaf] 타임리프 if unless 사용법 및 예제]]
 +==== th:block 사용법 ====
 +테이블에서 2개 이상의 td를 효과적으로 커스터마이징 하고자할 때 \\
 +예를 들어 colspan이나 rowspan 적용시 사용하면 효과적임
 +<code jsp>
 +<th:block th:if="${pojo.f == null}">
 +    <td colspan="2" th:text="#{nice.info}"/>
 +</th:block>
 +<th:block th:if="${pojo.f != null}">
 +    <td th:text="${pojo.f}"/>
 +    <td th:text="${pojo.g}"/>
 +</th:block>
 +</code>
 +
 +
 +
 +===== Parameter ======
 +
 +  * [[https://attacomsian.com/blog/thymeleaf-get-query-string-parameters|How to get query string parameters in Thymeleaf]]
 +
 ===== Tip ===== ===== Tip =====
 +이클립스 플러그인 설치:\\
 +  * Help >> Install New Software >>  http://www.thymeleaf.org/eclipse-plugin-update-site/ 를 입력합니다.
 \\ \\
 +
 +  * [[https://hyunsangwon93.tistory.com/19|Spring boot Thymeleaf 자주 사용하는 문법]]
 +
 ===== Troubleshooting ===== ===== Troubleshooting =====
-\\ +**''리눅스''** 환경에서 Controller의 반환값 맨 앞에 /가 들어가 있으면 안됩니다. \\ 
-===== Ref =====+thymeleaf 리졸버가 읽지를 못합니다. 
 +  * [[https://wonin.tistory.com/503|[AWS] ec2 환경에서 thymleaf 오류 잡기(template might not exist or might not be accessible by any of the configured Template Resolvers...)]]
 \\ \\
  
 +===== Ref =====
 +  * [[https://www.thymeleaf.org/index.html|Thymeleaf]]\\
 +  * {{ :wiki:main_category:thymeleaf:docs:usingthymeleaf.pdf |}}
 +  * [[https://smallgiant.tistory.com/95|Elvis operator & Safe Navigation operator]]
  
  
 +{{tag>도봉산핵주먹 thymeleaf 오션 주레피 타임리프}}
  
- 
-{{tag>도봉산핵주먹 python }} 
/volume1/web/dokuwiki/data/attic/wiki/thymeleaf.1594356867.txt.gz · 마지막으로 수정됨: 2022/03/10 19:52 (바깥 편집)