ABAP DUMP ERROR 24시

Thylmleaf 간단 용어 정리 본문

[WEB]Back-end/Spring MVC

Thylmleaf 간단 용어 정리

이운형 2022. 2. 18. 16:11
반응형

# 인프런 김영한의 스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술 개인적으로 정리한 글입니다.

 

 

 

Q.HTML 엔티티가 뭐야?

웹브라우저는 < 를 HTML의 태그로 인식한다.

따라서 HTML 태그가 아닌 문자로 표현할수 있는 방법

 

Q. 이스케이프가 뭐야?

HTML에서 사용하는 특수 문자를 HTML 엔티티로 변환하는 방법

 

 

 

Q . 타임리프에서 Un 이스케이프 하는 방법

1. th:text => th:utext 로 변경한다.

2. [[...]] = > [(...)] 로 변경한다.

 

Q. Thymeleaf 객체 접근 방법

1. Http 요청 파라미터 접근 ${param.paramData}

2. Http 세션 접근 ${session.sessionData}

3. 스프링빈 접근 ${@helloBean.hello('Spring!')}

 

Q . URL 접근처리방법@{...}

1. 경로 변수

/hello/data1/data2

@{/hello/{param1}/{param2}(param1=${param1}, param2=${param2})}

 

2. 경로 변수 + 쿼리 파라미터

/hello/data1?param2=data2

@{/hello/{param1}(param1=${param1}, param2=${param2})}

 

Q. literal 처리

1.문자는 반드시 '' 로 감싸야한다.

<span th:text ="'hello'"</span>

 

2. literal 대체 기법 사용시

<span th:text="|hello ${data}|"></span> 처럼  사용이 가능하니 리터럴대체 ||를 사용하자.

 

Q. ${#ids.("xxx")}의 기능은?

<div>등록 지역</div>
<div th:each="region : ${regions}" class="form-check form-check-inline">
    <input type="checkbox" th:field="${item.regions}" th:value="${region.key}"
           class="form-check-input">
    <label th:for="${#ids.prev('regions')}"
           th:text="${region.value}" class="form-check-label">서울</label>
</div>

 

다음과 같이 each로 반복문이 돌때 동적으로 생성되는 th:field=${item.regions}의 id 값을

 

동적으로 넣어준다.

 

 

 

 

반응형
Comments