Thymeleaf基础

首先,在html页面中要使用Thymeleaf模板引擎需要引入

<html xmlns:th = "http://www.thymeleaf.org"
      xmlns:layou="http://www.ultraq.net.nz/thymeleaf/layout">

使用 th:replace 引入公共模板,fragments 为包名,header为html页面名,header为header页面中命名的片段名

<div th:fragment="header">

<div th:replace="~{fragments/header :: header}"></div>

 HTML中画表格,${}变量表达式,其中可以为从后端传入的值,*{}变量表达式,为${}中传来的属性值,@{}链接表达式,其中可以为后端接口。

<table border="1">
    <thead>
    <tr>
        <td>ID</td>
        <td>Name</td>
        <td>Email</td>
    </tr>
    </thead>
    <tbody>
    <tr th:if="${userModel.userList.size()} eq 0">
        <td colspan="3">没有用户信息!</td>
    </tr>

    <tr th:each="user : ${userModel.userList}">
        <td th:text="${user.id}">1</td>
        <td th:text="${user.name}">zsp</td>
        <td th:text="${user.email}">kkk</td>
        <td ><a th:href="@{'/users/' + ${user.id}}" th:text="详情"></a> </td>
    </tr>
    </tbody>
</table>

啊啊啊啊啊啊,写的啥,完全不知道写啥啊,过几天自己看肯定都看不懂啊

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值