bphilipnyc bphilipnyc - 1 year ago 173
Java Question

Output a @Transient String value in Thymeleaf

I have a basic getter/setter in a POJO, the value for which I am displaying on a JSP using Thymeleaf via Hibernate.

<span class="myClass" th:text="${myClause}">clause here</span>

The value prints just fine for a run-of-the-mill getter/setter but when I introduce the
annotation on
, the value doesn't print.

Is this a limitation with Thymeleaf? Do I need to persist the value for it to evaluate?

I am using Thymeleaf 2.1.4.RELEASE.

Answer Source

After forking a Thymeleaf sample and trying it, I noticed that transient values are shown correctly. There is no issue with the Thymeleaf code. My error was because I did not also annotate the setter with @Transient.

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