Thymeleaf 和 Spring 的布尔条件 [英] Boolean condition with Thymeleaf and Spring
本文介绍了Thymeleaf 和 Spring 的布尔条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的网页中添加一个错误标志.如何使用 Thymeleaf 检查 Spring 模型属性是真还是假?
解决方案
布尔文字是 true
和 false
.
使用 th:if
你会得到如下代码:
或者如果您决定使用 th:unless
还有一个 #bools
实用程序类可供您使用.请参阅用户指南:http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#booleans
I'd like to add an error flag in my web page.
How can I to check if a Spring Model attribute is true or false with Thymeleaf?
解决方案 The boolean literals are true
and false
.
Using the th:if
you will end up with a code like:
<div th:if="${isError} == true">
or if you decide to go with the th:unless
<div th:unless="${isError} == false">
There is also a #bools
utility class that you can use. Please refer to the user guide: http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#booleans
这篇关于Thymeleaf 和 Spring 的布尔条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文