Basa
Basa

Reputation: 134

Thymeleaf inline text shows null Strings as 'null'

In thymeleaf 2.1.4, when evaluating null String values with

<p th:inline="text">[[${bean.myNullvar}]]</p>

The outlined html is

<p>null</p>

When I use it with th:text it works correctly:

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

is outlined as:

<p></p>

¿Is there any way to render String null values as empty ones with inlining? ¿How is it going to work in Thyeleaf 3, where inline is active by default?

Thanks in advance

Upvotes: 2

Views: 2181

Answers (1)

ndrone
ndrone

Reputation: 3582

Thymeleaf has some string utility method you can try

Here is the null safe toString.

${#strings.toString(obj)}

Upvotes: 4

Related Questions