制作< p>根据变量出现并在百里香中消失

发布于 2025-02-01 15:10:06 字数 255 浏览 2 评论 0原文

您好,我正在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

她说她爱他 2025-02-08 15:10:06

尝试以下尝试:

=“ $ {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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文