java - 如何通过按下按钮来替换 div 的内容
问题描述
我想在导航栏下方的容器中使用 th:insert 。每个按钮都会插入不同的代码。我知道有一个 th:if 但我不知道如何使用它来检查按钮是否被按下。对于这个问题,也许有比使用 th:insert 和 th:if 更好的解决方案?
我只是想更改容器的内容而不是重新加载到另一个页面。我已经准备好要插入页面的 html 文件。我正在使用 Spring Boot、Spring MVC、Thymeleaf
导航条码:
<nav class="navbar navbar-custom" aria-label="Desktop Navigation">
<div class="container">
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="link">Add User</a></li>
<li><a href="link">Users List</a></li>
</ul>
</div>
</div>
</nav>
容器代码:
<div class="row">
<div class="col-sm-12">
<th:block th:if="(What I should insert here?)">
<div th:insert="fragments/panelFragments :: addUserFragment" />
</th:block>
<th:block th:if="(What I should insert here?)">
<div th:insert="fragments/panelFragments :: usersListFragment" />
</th:block>
</div>
</div>
解决方案
推荐阅读
- python - numpy:如何设置精度打印 poly1d
- c++ - 如何在 C++ 中将 std::fstream 设置为类属性?
- python - 具有相同 xpath 的多个按钮
- highcharts - 如何显示在服务器端计算的直方图?
- c# - 如何使用 Ozeski SDK USB 相机拍摄快照?
- python - 将 kivy 应用程序转换为 apk 的问题(确认 SSL 证书的问题)
- c# - 在自定义 WebAPi 中调用 Azure Speech API 时进入无限循环
- cloud - 如何更改 Artifactory Cloud 中的 mimetypes 设置
- python - 氦气或硒不会单击按钮或链接
- r - R:霍尔特模型。无法绘制时间序列预测(预测)