thymeleaf 删除模板


thymeleaf 删除模板

 

 

******************

相关标签:th:remove

 

th:remove 属性值:

all:删除所在标签、子标签、文本

body:不删除所在标签删除,删除子标签、文本

tag:删除所在标签,不删除子标签、文本

all-but-first:删除所在标签的所有子标签(第一个子标签除外)

none:不执行任何删除操作

 

 

******************

示例

 

index.html

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div th:align="center" style="color: coral" th:remove="all">
    hello 瓜田李下
    <span th:text="瓜田李下"></span><br>
    <span th:text="海贼王"></span>
</div><br>

<div th:align="center" style="color: coral" th:remove="body">
    hello 瓜田李下
    <span th:text="瓜田李下"></span><br>
    <span th:text="海贼王"></span>
</div><br>

<div th:align="center" style="color: coral" th:remove="tag">
    hello 瓜田李下
    <span th:text="瓜田李下"></span><br>
    <span th:text="海贼王"></span>
</div><br>

<div th:align="center" style="color: coral" th:remove="all-but-first">
    hello 瓜田李下
    <span th:text="瓜田李下"></span><br>
    <span th:text="海贼王"></span>
</div><br>

<div th:align="center" style="color: coral" th:remove="none">
    hello 瓜田李下
    <span th:text="瓜田李下"></span><br>
    <span th:text="海贼王"></span>
</div>
</body>
</html>

 

***************

执行结果

 

th:remove="all":全部删除

 

th:remove="body":除所在标签外全部删除

                            

                               

th:remove="tag":删除所在标签,子标签、文本不删除

                            

 

th:remove="all-but-first":删除所有子标签(第一个除外),不删除文本

                            

 

th:remove="none":不执行任何删除操作

                            

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值