如何在百里香中设置全局变量?

sub*_*yal 8 thymeleaf

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

<span th:with="var=${someValue}" th:text="${var}"></span>
Run Code Online (Sandbox Code Playgroud)

如果我使用th:text变量中的值将被打印,我可以在同一个元素中使用该变量,有没有办法var在其他元素中使用

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

<span th:text="${var}"></span>
Run Code Online (Sandbox Code Playgroud)

我需要global scope在百里香中提供这个变量吗?

Mos*_*oye 6

var在开始body标记中定义

<body th:with="var=${var_value}">
Run Code Online (Sandbox Code Playgroud)