收藏夹吃灰系列(十二):Springboot配置Thymeleaf实现静态页面访问 | 超级详细,建议收藏!
2023-09-27 14:28:25 时间
一、前言
Springboot默认是不支持JSP的,默认使用thymeleaf模板引擎。所以这里介绍一下springboot结合Thymeleaf,实现模板实例以及途中遇到的问题。
二、配置与使用
1.引入jar。 在pom中加入thymeleaf对应的starter 依赖。
<!--模板引擎Thymeleaf-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2.在配置文件(application-dev.yml)中配置Thymeleaf模板参数。
#spring配置
spring:
thymeleaf:
cache: false
mode: LEGACYHTML5
prefix: classpath:/templates/
suffix: .html
重要参数解说:
cache: 是否缓存,开发模式下设置为false,避免改了模板还要重启服务器,线上设置为true,可以提高性能。一般改为false。
mode:配置视图模板类型,如果使用htm
相关文章
- SpringBoot到底是什么?
- springboot工程pom的两种配置方式
- springboot 配置Ehcache
- springboot的jackson的特有注解 @JsonIgnore, @JsonProperty等
- SpringBoot通过配置devtools实现热部署
- 精品springboot汽车票网上预订系统购票预约
- springboot实现前后端分离
- SpringBoot外部化配置本地调试
- SpringBoot 注解事务声明式事务
- idea下springboot框架使用hibernate和jpa连接池配置为hikari的方法
- springboot 使用consul 读取配置文件(遇到的坑太多,没记录)
- SpringBoot 集成MyBatis 中的@MapperScan注解
- WEB开发----springboot的登录拦截机制
- Springboot集成swagger2生成接口文档
- 在IDEA 、springboot中使用切面aop实现日志信息的记录到数据库
- SpringBoot系列七:SpringBoot 整合 MyBatis(配置 druid 数据源、配置 MyBatis、事务控制、druid 监控)
- SpringBoot源码解析之应用类型识别
- Springboot 发送短信验证码