spring boot模板

thymeleaf模板——它就是html页面
相关pom依赖

org.springframework.boot
spring-boot-starter-thymeleaf

Spring Boot官方文档建议在开发时将缓存关闭,那就在application.properties文件中加入下面这行
spring.thymeleaf.cache=false
正式环境还是要将缓存开启的

th:value`<html xmlns:th="http://www.thymeleaf.org">
    <tr th:each="user : ${users}">
    <td th:text="${user.uid}"></td>
    <td th:text="${user.userName}"></td>
    <td th:text="${user.desc}"></td>
</tr> 
<select>
    <option th:each="user :${users}" th:value="${user.uid}" th:text="${user.username}"></option>
</select>

freemarker模板
org.springframework.boot
spring-boot-starter-freemarker
`
application.yml文件的默认配置

spring:
thymeleaf:
cache: false
freemarker:
# 设置模板后缀名
suffix: .ftl
# 设置文档类型
content-type: text/html
# 设置页面编码格式
charset: UTF-8
# 设置页面缓存
cache: false
# 设置ftl文件路径,默认是/templates,为演示效果添加role
template-loader-path: classpath:/templates/role
mvc:
static-path-pattern: /static/**

list.ftl

角色列表 <#include 'commen.ftl'>

取值

wecome [${name!'未知'}] to page

非空判断

<#if name?exists>
hhhhhhhhhhhh哈哈哈哈哈
</#if>

条件表达式

<#if sex=='boy'> 男孩 <#elseif sex=='girl'> 女孩 <#else > 保密 <#list users as user>
ID姓名密码
${user.uid}${user.username}${user.password}

变量的设置(局部,全局的)

<#assign ctxl> ${springMacroRequestContext.contextPath}

include

<#include 'foot.ftl'>

login.ftl
版权信息
登陆1//进不去

登陆

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值