How can I capitalize a string showed by Thymeleaf into a page?
you can do it by
$string.toLowerCase()
or $string.toUpperCase()
#strings.capitalize(menuItem.desFnz)
will only capitalize the 1st character, where as #strings.toUpperCase(menuItem.desFnz)
will convert the entire string to uppercase. Here is the documentation for the Strings class.
Just adding to Pradeep Pati's point.
In case you are using it in the spring boot project where some of your values are coming from messages.properties
like In messages.properties file, You have something like:
email.dailyAlert.greeting.newTemplate = Dear {0},
Then to substitute the value in place of {0} (in the Title case), you need to write like the below line.
<p th:text="#{email.dailyAlert.greeting.newTemplate(${#strings.capitalize(orgSlug)})}"></p>
The final output will be:
Dear Organisation,