pursue wind pursue wind
首页
Java
Python
数据库
框架
Linux
中间件
前端
计算机基础
DevOps
项目
面试
书
关于
归档
MacOS🤣 (opens new window)
GitHub (opens new window)
首页
Java
Python
数据库
框架
Linux
中间件
前端
计算机基础
DevOps
项目
面试
书
关于
归档
MacOS🤣 (opens new window)
GitHub (opens new window)
  • mybatis

  • mybatis-plus

  • Spring

  • SpringBoot

    • 文档

      • SpringBoot+Security-发送短信验证码
      • SpringBoot-三大基本注解
      • SpringBoot-多模块
      • Springboot-秒杀项目
      • SpringBoot2-0响应式编程系列(一)-导读
      • SpringBoot统一异常处理
      • SpringBoot集成BootStrap
      • SpringBoot集成RabbitMQ
      • Springboot集成Thymeleaf
      • SpringBoot集成Thymeleaf模板
    • Log4j2配置
    • SpingBoot整合AOP
    • Spring Boot 2发送邮件手把手图文教程
    • Spring Boot 2实现分布式锁——这才是实现分布式锁的正确姿势!
    • Spring Boot 启动配置原理
    • SpringBoot 启动 Banner
    • SpringBoot 定时任务
    • SpringBoot 引入本机jar包 配置
    • SpringBoot 线程池配置 定时任务,异步任务
  • SpringSecurity

  • SpringCloud

  • 单元测试框架Mockito
  • 框架
  • SpringBoot
  • 文档
pursuewind
2020-11-23

SpringBoot集成Thymeleaf模板

#1 创建一个maven工程,这个应该都会 #2 pom文件加入下面内容即可(版本号自己改

    <parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.4.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>

    <dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-thymeleaf</artifactId>
	</dependency>
1
2
3
4
5
6
7
8
9
10
11

#3 写一个入口类 #4 写个home.html #5 在工程的resources目录下创建一个application.properties文件,这个文件是spring-boot用来配置一些工程属性用的

# 配置服务器端口,默认是8080,可以不用配置
server.port=8080
# 模板配置
# 这个开发配置为false,避免改了模板还要重启服务器
spring.thymeleaf.cache=false
# 这个是配置模板路径的,默认就是templates,可不用配置
spring.thymeleaf.prefix=classpath:/templates/
# 这个可以不配置,检查模板位置
spring.thymeleaf.check-template-location=true
# 下面3个不做解释了,可以不配置
spring.thymeleaf.suffix=.html
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html

# 模板的模式
spring.thymeleaf.mode=HTML5

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Last Updated: 2023/01/30, 11:01:00
Springboot集成Thymeleaf
Log4j2配置

← Springboot集成Thymeleaf Log4j2配置→

Theme by Vdoing | Copyright © 2019-2023 pursue-wind | 粤ICP备2022093130号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
  • 飙升榜
  • 新歌榜
  • 云音乐民谣榜
  • 美国Billboard榜
  • UK排行榜周榜
  • 网络DJ