2017-06-29 6 views
-1

場合、私はそれを置くことが可能であるかどうかを知りたいし、他の場合でしょうThymeleaf HTML私はThymeleaf HTMLページにコードのこの部分を持って、同じ行の他の

<div th:if="${book.htmlIconColor != null}" > 
<i class="fa fa-exchange fa-2x" th:style="${'color:' + book.htmlIconColor + '; text-align: center;'}" aria-hidden="true"></i>      
</div> 
<div th:if="${book.htmlIconColor == null}" > 
<i class="fa fa-exchange fa-2x" aria-hidden="true"></i>      
</div> 

答えて

2

何かを試してみてくださいこのような例:

condition ? first_expression : second_expression; 

<i class="fa fa-exchange fa-2x" aria-hidden="true" th:style="${book.htmlIconColor} ? 'color:' + ${book.htmlIconColor} + '; text-align: center;' : 'text-align: center;'"></i> 
関連する問題