我正在开发一个使用Thymeleaf作为模板引擎的Spring MVC应用程序,并且我想将页面中显示的某些字符串大写。在我的页面上,我有类似以下的内容:
<li class="com__nav-item" th:each="menuItem : ${#authentication.principal.listaFunzioniUtente}">
<a href="" class="com__nav-link centered">
<span class="blue-line animate scaleIn delay-3" style="font-size: 1.4em; text-align: center;" th:text="${#strings.capitalize(menuItem.desFnz)}"></span>
<span class="white-circle animate scaleIn delay-5"></span>
</a>
</li>
正如您在前面的代码中所看到的,在第一个<span>
标签中,我展示了menuItem
对象的desFnz
属性内的字符串。
它可以正常工作,但我的问题是我想将所有字符都大写,所以我尝试做:
th:text="${#strings.capitalize(menuItem.desFnz)}"
我使用了#strings.capitalize()
但它不起作用,实际上在我的页面中我仍然得到了未大写的文本。为什么?我错过了什么?如何解决这个问题?
text-transform: uppercase;
将其留给 CSS。 - MyBrainHurts