2016-03-15 56 views
2

我正在使用Thymeleaf作爲模板引擎的Spring MVC應用程序,我正嘗試使用一些字符串顯示在我的頁面中。在我的網頁我有這樣的事情:如何將Thymeleaf顯示的字符串轉換爲頁面?

<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物業內的字符串。

它工作正常,我的問題是,我想利用所有的字符,所以我試圖做的:使用#strings.capitalize()

th:text="${#strings.capitalize(menuItem.desFnz)}" 

但它不能正常工作,其實在我的網頁我仍然獲得文字但沒有大寫。爲什麼?我錯過了什麼?我該如何解決這個問題?

+0

您使用哪種Thymeleaf版本? – Zakaria

+0

@ Zakaria我正在使用ThymeLeaf的2.1.4.RELEASE – AndreaNobili

+2

您正在使用類和樣式屬性。因此,作爲最後的手段,您仍然可以通過添加'text-transform:uppercase;'將其留給CSS – MyBrainHurts

回答