I'm using Thymeleaf 3.0.11 with Spring 4.3.22, no Boot. Have this code:
<tbody class="clientdata section" th:data-id="${formModel?.client?.person?.userId ?: ''}">
It works fine when the userId has a value. Then the output is, for example:
<tbody class="clientdata section" data-id="178051">
However, when the userId is null, the attribute disappears altogether:
<tbody class="clientdata section">
If i specify some dummy value in case of null userId, it works fine:
<tbody class="clientdata section" th:data-id="${formModel?.client?.person?.userId ?: '0'}">
But why not just render attribute with empty value? I.e. i would like it to render:
<tbody class="clientdata section" data-id="">
in case the userId is null.