Spring Boot入门——thymeleaf模板使用

Posted Miss_wang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring Boot入门——thymeleaf模板使用相关的知识,希望对你有一定的参考价值。

使用步骤

1、在pom.xml中引入thymeleaf

    <!-- thymeleaf插件 -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
        <version>1.5.3.RELEASE</version>
    </dependency>    

2、关闭thymeleaf缓存

  创建application.properties资源文件

<!-- 关闭thymeleaf缓存 -->
spring.thymeleaf.cache=false

#spring.thymeleaf.prefix=classpath:/templates/  

#spring.thymeleaf.suffix=.html 

#spring.thymeleaf.mode=HTML5

#spring.thymeleaf.encoding=UTF-8  

# ;charset=<encoding> is added 

#spring.thymeleaf.content-type=text/html 

3、编写thymeleaf模板文件

4、编写模板请求controller


以上是关于Spring Boot入门——thymeleaf模板使用的主要内容,如果未能解决你的问题,请参考以下文章

Spring Boot快速入门:thymeleaf

Spring Boot入门——全局异常处理

使用spring-boot-starter-web和thymeleaf时填充下拉列表

SpringBoot--Thymeleaf入门使用

java后端开发第四篇:springboot中thymeleaf入门

java后端开发第四篇:springboot中thymeleaf入门