制作< p>根据变量出现并在百里香中消失
您好,我正在Spring Boot和Thymeleaf中构建一个应用程序,我有一个段落,我只想在具有价值的情况下才能使其出现。如果不是,我不希望它出现。
这是我尝试过的代码:
<h2 th:text="'Raspuns: ' + ${raspuns}" th:disabled="${raspuns}==null"></h2>
但是当我输入页面时,它说:raspuns:null我想让那个消失。
Hello I am building an application in Spring Boot and Thymeleaf and I have a paragraph that I want to make it appear only if it has a value. If it does not I do not want it to appear.
Here is the code that I have tried:
<h2 th:text="'Raspuns: ' + ${raspuns}" th:disabled="${raspuns}==null"></h2>
But when I enter the page it says: Raspuns: null I want to make that dissapear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试以下尝试:
=“ $ {raspuns}!= null” th:text =“'raspuns:' + $ {raspuns}”
&lt; h2 th: if 关于文档中的条件:
try this:
<h2 th:if="${raspuns} != null" th:text="'Raspuns: ' + ${raspuns}"></h2>
see more about conditions in the documentation:
Thymeleaf Conditional Evaluation