thymeleaf

1.配置文件在application.yml:

server:
  port: 8900
spring:
  # THYMELEAF
  thymeleaf:
    #开启模板缓存(默认值:true)
    cache: false
    #Check that the template exists before rendering it.
    check-template: true
    #检查模板位置是否正确(默认值:true)
    check-template-location: true
    #开启MVC Thymeleaf视图解析(默认值:true)
    enabled: true
    #模板编码
    encoding: UTF-8
    #要运用于模板之上的模板模式。另见StandardTemplate-ModeHandlers(默认值:HTML5)
    mode: LEGACYHTML5
    #在构建URL时添加到视图名称前的前缀(默认值:classpath:/templates/)
    prefix: classpath:/templates/
    #在构建URL时添加到视图名称后的后缀(默认值:.html)
    suffix: .html
    #Thymeleaf模板解析器在解析器链中的顺序。默认情况下,它排第一位。顺序从1开始,
    #只有在定义了额外的TemplateResolver Bean时才需要设置这个属性。
    template-resolver-order: 1

2.新建html文件:

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>welcome</title>
    <meta http-equiv="Content-Type" content="text/html;    ch arset=UTF-8"/>
    <link rel="stylesheet" type="text/css" media="all" href="../../css/gtvg.css" th:href="@{/css/gtvg.c ss}"/>
</head>
<body>
<p th:text="'hello, ' + ${name} + '!'"/>
</body>
</html>

 

3.新建controller:

运行http://localhost:8900/hello

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值