【发布时间】:2020-11-28 03:41:47
【问题描述】:
是否可以在 thymeleaf 中设置一个变量,然后根据选择元素中的选项更改它,然后根据选择显示特定的 div?这就是我的意思。
我在选择中有三个选项:
1) DESKTOP_PC
2) LAPTOP_PC
3) TABLET_PC
当用户选择DESKTOP_PC 时,我想显示带有相关输入的 div。同样,如果它是 LAPTOP_PC 或 TABLET_PC。
唯一的问题是,我不知道该怎么做。
另外,我有以下几点:
在我的入门类中,我有一个枚举类:
public static enum Type {
DESKTOP_PC,
LAPTOP_PC,
TABLET_PC
}
在我的 Thymeleaf 表单中,我可以通过以下方式访问和显示此枚举:
<div class="section-question">
<p>Type</p>
<select name="type" th:field="$*{type}">
<option th:each="type : ${T(com.project.entities.Entry.Type).values()}" th:value="${type}" th:text="${type}" ></option>
</select>
</div>
Any help would be much appreciated!
Thanks
【问题讨论】:
标签: java html spring spring-boot thymeleaf