转自:
下文笔者将讲述SpringBoot集成ThymeLeaf的方法,如下所示:
实现思路:
1.在pom.xml中引入ThymeLeaf的相关依赖
2.在Templates文件夹下编写相应的模板文件
例:
1.pom.xml 添加ThymeLeaf依赖2.编写模板 org.springframework.boot spring-boot-starter-thymeleaf java265.com ThymeLeaf模板 This is ThymeLeaf file
3.编写Controller @Controller public class TestController { @RequestMapping("/index") public String test(Model m) { m.addAttribute("msg","adeal love java."); return "ThymeLeaf/index"; } } -----运行springboot即可访问 http://localhost:8080/index 即可输出以下效果
