一、th:text字符串拼接
user.name从后台传来的变量,${user.name}获得变量值。文本链接:用“+”符号,也可以用“|”符号。
若user.name="张三",解析结果为:<span>Welcome,张三</span>
<span th:text="'Welcome,'+${user.name}">
<span th:text="|Welcome, ${user.name}|">二、th:action字符串拼接
若user.userId=1,解析结果为:<form action="/user/1"></form>
<form th:action="@{'/user/'+${user.userId}}"></form>
<form th:action="@{/user/{userId}(userId=${user.userId})}"></form>
本文介绍如何使用Thymeleaf中的表达式语法进行字符串拼接,包括th:text属性中使用变量和th:action属性中设置表单提交路径。

2436

被折叠的 条评论
为什么被折叠?



