1 How to customize the homepage
Source code shows the execution process
2 template engine
https://docs.spring.io/spring-boot/docs/2.1.6.RELEASE/reference/htmlsingle/#using-boot
import dependencies in pom.xml
We are all developed by version 3.x
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-java8time</artifactId>
</dependency>
A test
as long as you need to use it, you thymeleaf
only need to import the corresponding dependencies! We will put the html file to our templates
test
in whichTestController.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";
}
}
Test th:text th:utext
testth:each