cuongngo cuongngo - 1 year ago 66
HTML Question

What is the text in a tag when it has thymeleaf in mean?

I'm new in Thymeleaf and facing some lines of code like:

<p th:text="${message}">Hi!</p>

is specified in the controller of the view here. The result of above line is the value of the
variable. So, what is the actual role of
text above? I've tried to set
to another variable which doesn't exist and nothing happened but the white screen.

Answer Source

The actual role of Hi! text is to be able to display the static view of the page in the browser during prototyping. Because there is no such attribute like th:text in HTML, value Hi! is just a stub.

During the processing of the template this value will be substituted by the value resulting from the evaluation of ${message}.
Also during the processing in the dynamic view (as well as in generated source) the value Hi! will be ignored.

This feature helps your designer and developer to work on the very same template file and reduce the effort required to transform a static prototype into a working template file. The ability to do this is a feature called Natural Templating.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download