Top

Thymeleaf模版中的取值


最近在项目中使用到了springBoot自带的Thymeleaf模版,之前也没用过,研究了一下它的语法,在此记录下

js取model的值

1
2
3
4
<script th:inline="javascript">
var message = [[${message}]];
console.log(message);
</script>

页面取值

1
2
3
<a th:text="${name}"></a>
或者
<a th:value="${name}"></a>

循环取值

1
2
3
4
5
6
7
<tr th:each="article: ${articleList}"> 
<td th:text="${article.title}"></td>
<td th:text="${article.name}"></td>
<td th:text="${article.vcTitle}"></td>
<td th:text="${article.read}"></td>
<td th:text="${article.author}"></td>
</tr>


未经允许不得转载: 幻凡ss » Thymeleaf模版中的取值