gpt4 book ai didi

thymeleaf - 如何在 thymeleaf 中设置全局变量?

转载 作者:行者123 更新时间:2023-12-04 07:34:34 27 4
gpt4 key购买 nike

我在前端使用thymeleaf,我知道variable中的thymeleaf概念

<span th:with="var=${someValue}" th:text="${var}"></span>

如果我使用 th:text,变量中的值将被打印,并且我可以在同一元素中使用该变量。有没有办法在其他元素中使用 var呢?
<span th:with="var=${someValue}"></span>

<span th:text="${var}"></span>

我需要为该变量提供 global scope,在 thymeleaf 中可能吗?

最佳答案

在开始的var标记中定义body

<body th:with="var=${var_value}">

关于thymeleaf - 如何在 thymeleaf 中设置全局变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37322752/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com