thymeleaf配置html资源路径,SpringBoot集成Thymeleaf模板引擎

本文介绍了如何在SpringBoot中配置Thymeleaf模板引擎,包括maven依赖、application.yml配置以及Thymeleaf的使用。Thymeleaf语法简洁,但渲染效率相对较低。示例中详细展示了html文件的组织结构、Thymeleaf语法的使用,如数据遍历和静态资源引用。
摘要由CSDN通过智能技术生成

简单介绍

目前在JavaEE领域有几中比较常用的模板引擎,分别是Jsp、Velocity、Freemarker、Thymeleaf,对Freemark语法不是特别熟悉,不过对于前端页面渲染效率来说,jsp其实还是最快的,Velocity次之。Thymeleaf虽然渲染效率不是很快,但是语法方面是比较轻巧的,Thymeleaf语法比Velocity轻巧,但是渲染效率不如Velocity

maven配置

因为引入了SpringBoot的parent工程,所以不需要写版本号

org.springframework.boot

spring-boot-starter-thymeleaf

application.yml配置#添加Thymeleaf配置

thymeleaf:

cache: false

prefix: classpath:/templates/

suffix: .html

mode: HTML5

encoding: UTF-8

content-type: text/html

application.yml:server:

port: 8081#logging:#  config: classpath:logback_spring.xml.bat#  level:#    com.muses.taoshop: debug#  path: /data/logsspring:

datasource:    # 主数据源

shop:

url: jdbc:mysql://127.0.0.1:3306/taoshop?autoReconnect=true&useUnicode=true&characterEncoding&

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值