thymeleaf语法

扫码查看

链接

<a th:href="@{userList}">1、@{userList}</a><br/>
<a th:href="@{./userList}">2、@{./userList}</a><br/>
<a th:href="@{../tiger/home}">3、@{../tiger/home}</a><br/>
<a th:href="@{/tiger/home}">4、@{/tiger/home}</a><br/>
<a th:href="@{https://www.baidu.com}">5、@{https://www.baidu.com}</a><br/>

链接参数

<a th:href="@{userList(id=9527)}">1、@{userList(id=9527)}</a><br/>
<a th:href="@{userList(id=9527,name=华安)}">2、@{userList(id=9527,name=华安)}</a><br/>
<a th:href="@{userList(id=9527,name=${userName})}">3、@{userList(id=9527,name=${userName})}</a><br/>

文本

中间无空格时,可以不加单引号

<p th:text="China">中国</p>

空格属于特殊字符,必须使用单引号包含整个字符串

<p class="css1 css2" th:class="'css1 css2'">样式</p>

下面如果没用单引号 th:text="Big China",则页面直接报错

<p th:text="'Big China'">中国</p>

后台使用:model.addAttribute("info", "Love you 中国"); 传值有空格也是没有问题的

<p th:text="${info}">info</p>

后台传值字符串有空格是可以的,可以使用 + 进行字符串连接

<p th:text="'small smile'+',very good.'">浅浅的微笑</p>

==rty==

01-01 16:41
查看更多