1 홈페이지 커스터마이징 방법
소스 코드는 실행 프로세스를 보여줍니다.
2 템플릿 엔진
https://docs.spring.io/spring-boot/docs/2.1.6.RELEASE/reference/htmlsingle/#using-boot
pom.xml의 종속성 가져 오기
우리는 모두 버전 3.x로 개발되었습니다.
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-java8time</artifactId>
</dependency>
테스트
를 사용해야하는 thymeleaf
한 해당 종속성 만 가져 오면 됩니다! html 파일을 templates
테스트 할 것
입니다.
TestController.java
package com.zs.helloword.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
// 在templates目录下的页面 只能通过controller来跳转
// 需要模板引擎的支持 thymeleaf
@Controller // 跳到一个页面
public class TestController {
@RequestMapping("/test")
public String test(Model model) {
model.addAttribute("msg","hello,springboot!");
return "test";
}
}
테스트 th:text th:utext
테스트th:each