简单介绍
目前在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&