you can either use thymeleafs objects utility class Objects or validate the object before passing it to the template.
i prefer the prevalidation as you normally do not want to hack around in your template. also that way you keep your data loosely coupled from the view.