SpringBoot(二)thymeleaf模板的引入

时间:2023-03-10 07:01:37
SpringBoot(二)thymeleaf模板的引入

接着上一次的配置

1.在pom文件中添加thymeleaf模板的引入,

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

位置如图:

SpringBoot(二)thymeleaf模板的引入

2.在templates包下新建hello.html文件

SpringBoot(二)thymeleaf模板的引入

3.在HelloController中添加,如图

SpringBoot(二)thymeleaf模板的引入

启动项目后,访问:http://localhost:8080/zm/hello

SpringBoot(二)thymeleaf模板的引入

总结:只是简单的配置,没有深入,再下一节深入了解一下,thhymeleaf是可以替代jsp的。