Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- 리눅스
- 스프링부트
- Oracle
- 스프링 부트 쇼핑몰 프로젝트 with JPA
- Spring Security
- 플러터
- backjoon
- javascript
- 프로그래머스
- 데이터베이스
- 스프링
- CS지식
- Flutter
- 네트워크
- python
- 자료구조
- postgresql
- 자바스크립트
- JPA
- 자바
- spring
- DB
- 시큐리티
- 파이썬
- baekjoon
- Java
- 백준
- springboot
- CS
- 데이터
Archives
- Today
- Total
Jin's Dev Story
[Thymeleaf] Thymeleaf 본문
Thymeleaf
서버 사이드 템플릿 엔진의 한 종류
html 태그에 속성을 추가해 페이지에 동적으로 값을 추가하거나 처리할 수 있다.
서버 사이드 렌더링 하지 않고 브라우저에 띄워도 정상적인 화면을 볼 수 있다.
//상단에 적어주면 타임리프 사용 가능
// Gradle - build.gradle
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
Controller
@Controller
public class ThymeleafController {
@GetMapping(value = "/thymeleaf/ex1")
public String ex1(Model model) {
model.addAttribute("data", "SpringBoot Study");
return "thymeleaf/ex1";
}
}
View
<!DOCTYPE html>
<html xmlns:th="http://wwww.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Insert title here></title>
</head>
<body>
<h1>Hello World!!!</h1>
<p th:text="{data}">스프링 부트 수업중!!</p>
</body>
</html>
application.properties
# Live Reload 기능 활성화
spring.devtools.livereload.enabled=true
# Thymeleaf cache 사용 중지
spring.thymeleaf.cache=false
## 추가사항
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.devtools.remote.restart.enabled=true
'Web & Android > Thymeleaf' 카테고리의 다른 글
[Thymeleaf] 날짜 변환 (0) | 2023.10.17 |
---|---|
[Thymeleaf] 기본 문법 (1) | 2023.10.17 |
[Thymeleaf] 페이지 레이아웃 (1) | 2023.10.17 |