Relative Content

Tag Archive for spring-bootspring-mvcspring-validatorspring-thymeleaf

Spring + Thymeleaf + Validation ignoring custom messages on validation annotations and going with their own

I have a typical Spring Boot (3.3.2) MVC application using validation and thymeleaf (3.1.2.RELEASE), and I’m finding that Thymeleaf seems to disregard the i18n messages specified in the validation annotation, attempting some other instead. In other words, if an annotation specifies “{A}” as a message, thymeleaf instead tries to use a different message key which seems to be the name of the annotation+the path of the property (e.g., for @Size attached to a “name” property in a “test” bean, it tries to use “Size.test.name” instead).