And*_*ili 7 spring spring-mvc capitalization thymeleaf
我正在使用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>
Run Code Online (Sandbox Code Playgroud)
正如您在前面的代码中看到的,在第一个<span>标记中,我desFnz在menuItem对象的属性中显示了一个字符串.
它工作正常,我的问题是我想要大写所有字符,所以我试着这样做:
th:text="${#strings.capitalize(menuItem.desFnz)}"
Run Code Online (Sandbox Code Playgroud)
使用#strings.capitalize()但它无法正常工作,实际上在我的页面中我仍然获得了文本但没有大写.为什么?我错过了什么?我该如何解决这个问题?
Pra*_*ati 18
#strings.capitalize(menuItem.desFnz)只会将第一个字符大写,其中as #strings.toUpperCase(menuItem.desFnz)将整个字符串转换为大写.这是Strings类的文档.
| 归档时间: |
|
| 查看次数: |
12094 次 |
| 最近记录: |