Thymeleaf常见属性

参考文档

thymeleaf 语法——th:text默认值、字符串连接、th:attr、th:href 传参、th:include传参、th:inline 内联、th:each循环、th:with、th:if_猎人在吃肉的博客-CSDN博客

【Thymeleaf】Thymeleaf中的判断语句_thymeleaf 判断_飝鱻.的博客-CSDN博客 

thymeleaf中th:text和th:utext的区别_th:text th:utext_雪心玉竹的博客-CSDN博客

thymeleaf块标签(空标签)th:block,标签本身不显示_程序员刘杨 (yyjjssnn.cn)

代码演示 

@Controller
public class TestController {

    @Autowired
    MenuService menuService;


    @GetMapping(value = "/index")
    public String index(Model model) {
        List<Menu> list = menuService.list();
        model.addAttribute("list", list);
        model.addAttribute("name", "吕怡婷");
        model.addAttribute("age", 22);
        return "/layui/index";
    }

    @PostMapping(value = "/insert")
    public String insert() {
        return null;
    }

    @GetMapping(value = "/delete")
    public String delete() {
        return null;
    }
}
@Controller

public class Test2Controller {
    @Autowired
    MenuService menuService;


    @GetMapping(value = "/skip")
    public String skip(Model model,String name,String age) {
        model.addAttribute("age", age);
        model.addAttribute("name", name);
        return "/layui/skip";
    }
}
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/lib/layui-v2.7.6/css/layui.css">
</head>
<body>
<link rel="stylesheet" href="/lib/layui-v2.7.6/layui.js">
<!--遍历-->
<div th:each="menu:${list}">
    <span th:text="${menu.menuName}"></span>--<span th:text="${menu.id}"></span>
    <br>
</div>
<!--测试text-->
<span th:text="${name}?'ok':'on'"></span>
<br>
<span th:text="${menu1}"></span>
<br>
变量:[[${name}]]
<br>
<!--字符串贫拼接-->
<span th:text="|${name}喜欢吃辣喜喜|"></span>
<br>
<!--跳转-->
<a th:href="@{/skip(name=${name},age=${age})}">跳转测试</a>
<!---->
<div th:with="name3=${name}+'xixix'">
    <p th:text="${name3}">ha</p>
</div>
<p th:text="${name3}">jjj</p>

<h3> th:remove </h3>
<div >
    all:<div th:remove="all"><div id="hello1">你好11</div></div>
    body:<div th:remove="body"><div id="hello2">你好11</div></div>
    tag:<div th:remove="tag"><div id="hello3">你好11</div></div>
    tag:<div th:remove="none"><div id="hello4">你好11</div></div>
</div>

<th:block th:if="${age}==23">
    <div>hahahaaaa</div>
    <div>oooooo</div>
</th:block>

<!--<th:block th:replace="${name}" />-->
</body>
</html>

自学 使用thymeleaf提交form表单给controller(springboot)_thymeleaf提交表单_梦梦~~的博客-CSDN博客

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值