We expect that the th: each attribute will be executed before the th: text so that we get the desired results, but given the fact that the HTML / XML standards have no meaning for the order of the attribute in the tag, the priority mechanism must be set in the attributes themselves , to be sure that this will work as expected.
Thus, all Thymeleaf attributes define a numeric value that sets the order in which they are executed in the tag. This order: ')
Order
Functionality
Attributes
one
Inclusion of fragments
th: insert th: replace
2
Fragment iteration
th: each
3
Conditional execution
th: if th: unless th: switch th: case
four
Local variable definition
th: object th: with
five
The main attribute modification
th: attr th: attrprepend th: attrappend
6
Specific attribute modification
th: value th: href th: src ...
7
Text (tag body modification)
th: text th: utext
eight
Fragment definition
th: fragment
9
Removing a fragment
th: remove
This priority mechanism means that the above iteration fragment will produce exactly the same results if the attribute position is inverted (although it will be slightly less readable):