how do I set this in a variable ?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

how do I set this in a variable ?

winzip
This post was updated on .
I have this print ...

<p th:text="${rootKey}"></p>

Is it possible to  set  this ${rootKey}  in a variable in the page ?  

What is the syntax to set this in a variable and print the variable in page ?
Reply | Threaded
Open this post in threaded view
|

Re: how do I set this in a variable ?

Emanuel
Administrator
Yes, you can use the th:with attribute to create a local variable, scoped to the element, and all other elements within it, where it was declared:

<p th:with="rootKey='test'" th:text="${rootKey}"></p>