Spring

[Spring] Thymeleaf

quedevel 2020. 3. 10. 16:37
728x90
반응형

Thymeleaf is a modern server-side Java template engine for both web and standalone environments.

Thymeleaf's main goal is to bring elegant natural templates to your development workflow — HTML that can be correctly displayed in browsers and also work as static prototypes, allowing for stronger collaboration in development teams.

With modules for Spring Framework, a host of integrations with your favourite tools, and the ability to plug in your own functionality, Thymeleaf is ideal for modern-day HTML5 JVM web development — although there is much more it can do.

아주 간단하게 예제를 만들어 보자

pom.xml 에 thymeleaf 추가

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>

 스프링부트 프로젝트로 했다면 반드시 위에껄로 적용해야한다.

 

TestController.java

@Controller
public class TestController {


    @GetMapping("/")
    public String getHome(){
        return "index";
    }

    @GetMapping("/ex1")
    public String getEx1(){
        return "ex1";
    }
    
}

 

resources/templates에 index.html과 ex1.html 추가

 

결과

728x90
반응형

'Spring' 카테고리의 다른 글

[Spring] Thymeleaf를 이용해 데이터 다루기  (0) 2020.03.13
[Spring] Swagger  (0) 2020.03.12
[Spring] Mustache  (0) 2020.03.12
[Spring] Thymeleaf 문법  (0) 2020.03.11
[Spring] Spring boot를 이용해 MyBatis 셋팅하기  (0) 2020.03.01