spring boot web笔记:
首页:
只需要将index.html放到下面的目录下
放到这个目录下是无法直接访问到的
在templates目录下的所有页面,只能通过contronller来跳转,这个需要模板引擎thymeleaf
thymeleaf:
提供使用 Thymeleaf 视图构建 MVC web 应用的支持。
开发传统Java WEB工程时,我们可以使用JSP页面模板语言,但是在SpringBoot中已经不推荐使用了。SpringBoot支持如下页面模板语言
Thymeleaf
FreeMarker
Velocity
Groovy
JSP
这样可以使用html,实现动态网页设计,屏蔽掉传统的jsp
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-java8time</artifactId>
</dependency>
但是导入的时候要注意thymeleaf版本,thymeleaf版本要比spring boot(应该是springboot自动的thymeleaf)高