<html lang="en" xmlns:th="http://www.thymeleaf.org">

*文本text区别

<!--区别一个不可以解析标签,-->
<h1 th:text="${title}">欢迎</h1>
<!--区别一个可解析标签-->
<h1 th:utext="${title}">欢迎</h1>

*循环获取 text的值

<h3 th:each="name:${data}" th:text="${name}">在这显示名字</h3>

*处理网址

<a href="" th:href="@{/user}">点我</a>

*a 标签的连接写法
在配置文件中配置通用地址

server.servlet.context-path=/dev

a 标签会自动在前面加上这个地址

<!--连接写法-->
<!--这种写法会在前面自动拼接context-path-->
<a href="" th:href="@{/dep/list}">对的链接/dep/list</a>

*form表单

<form action="" th:action="@{/user}">
    <input type="text" name="" th:value="${name}">
</form>

*fragment 与replace, include

fragment 是写通用片段的 创建一个html 专写它

<div class="fg" th:fragment="footer" >

    <h1>首页</h1>

</div>

在其他页面调取

replace 与include 的区别

<!--引入片段-->
<!--替换 保留的内层标签-->
<div class="emp" th:replace="fragmets::footer"></div>
<!--导入 保留的外层标签-->
<div class="emp" th:include="fragmets::footer"></div>
posted on 2019-06-30 17:54  脑抽不要停  阅读(124)  评论(0编辑  收藏  举报