thyemleaf

导入依赖

  <!--thymeleaf模板-->
      <dependency>
          <groupId>org.thymeleaf</groupId>
          <artifactId>thymeleaf-spring5</artifactId>
      </dependency>
      <dependency>
          <groupId>org.thymeleaf.extras</groupId>
          <artifactId>thymeleaf-extras-java8time</artifactId>
      </dependency>

将html页面放在templates下就可。html需要导入thyemleaf约束

<html lang="en" xmlns:th="http://www.thymeleaf.org">

建议在使用thymeleaf时关闭缓存,否则会产生很大开销

spring.thymeleaf.cache=false
#thymeleaf是一个模板引擎,缓存的意思是加载一次模板之后便不会在加载了,对于生产环境应该加上缓存,但是在开发过程中如果打开缓存,不方便开发人员调试。试想一下,改一行html,就需要重启服务器,肯定是不方便的。
#总结一下:
#本地开发环境下,需要把缓存关闭,否则调试成本太大。其他环境下缓存都需要打开。

详细语法看在线文档

posted @ 2023-01-11 11:22  Fannaa  阅读(27)  评论(0)    收藏  举报