Thymeleaf基本语句用法

**Thymeleaf 内置对象
1,调用内置对象一定要用
2,大部分的内置对象都以 s 结尾 strings、numbers、dates
**
th:text 页面输出

<span th:text="页面输出"></span>

th:value 可以将一个值放入到 input 标签的 value 中

<input text="text" th:value="在输入框中"/>

th:if 条件判断

<span th:if="${sex} == ' 男 '"> 
性别:男 
</span> 
<span th:if="${sex} == ' 女 '"> 
性别:女 
</span>

th:switch 选择语句

<div th:switch="${id}"> 
	<span th:case="1">ID 为 1</span> 
	<span th:case="2">ID 为 2</span>
	<span th:case="3">ID 为 3</span> 
</div>

th:each 迭代遍历

<table border="1"> 
	<tr> 
		<th>ID</th> 
		<th>Name</th> 
		<th>Age</th> 
	</tr> 
	<tr th:each="u : ${list}"> 
		<td th:text="${u.userid}"></td>
		 <td th:text="${u.username}"></td>
 		 <td th:text="${u.userage}"></td> 
	 </tr> 
</table>

URL类型
基本语法:@{}
1.url传递实参

<a th:href="@{/ss(id=1,name=zs)}">相对路径-传参</a>

2.相对于服务器路径的根

<a th:href="@{~/project/resourcename}">相对于服务器的根</a>

3.在 url 中通过 restful 风格进行参数传递

<a th:href="@{/path/{id}/sss(id=1,name=zs)}"> 相 对 路 径 - 传 参 -restful</a>
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

三分天注定,七分靠打拼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值