我该如何解决这个问题?
<div th:if="${showContent}=='true'" id="container-two" >
<div class="container-linux">
<div><img class="col"
style="width:50px;" src="" th:src="@{/images/linux.png}" alt=""><br>
<label >VM Name is</label>
<a style="font-weight: bold;" th:text="${vmnameshowlinux}" ></a><br>
<label >VM IpAddress is</label>
<a style="font-weight: bold;" th:text="${ipaddresslinux}" ></a></div>
<a th:href="@{/launchconsole}" class="btn btn-success">Launch RDP</a>
</div>
<div class="container-windows">
<div><img class="col"
style="width:50px;" src="" th:src="@{/images/windows.png}" alt=""><br>
<label >VM Name is</label>
<a style="font-weight: bold;" th:text="${vmnameshowwin}" ></a><br>
<label >VM IpAddress is</label>
<a style="font-weight: bold;" th:text="${ipaddresswin}" ></a></div>
<a th:href="@{/launchconsole}" class="btn btn-success">Launch RDP</a>
</div>
</div>
`
String showContent="true";
modelandview.addObject("showContent", showContent);
`
我想通过在 Spring Boot thymeleaf 项目中的 showContent 对象中传递真实值来显示容器二
您应该传递一个常规布尔值:
boolean showContent = true;
modelandview.addObject("showContent", showContent);
然后 Thymeleaf 应该看起来像:
<div th:if="${showContent}" id="container-two" >
.
.
.
</div>