Java Thymeleaf th:开关,每个th:开关
在以下情况下,如何为枚举中的值应用th:each on th:switchJava Thymeleaf th:开关,每个th:开关,java,spring-mvc,thymeleaf,Java,Spring Mvc,Thymeleaf,在以下情况下,如何为枚举中的值应用th:each on th:switch public enum Framework { ABC0(0, "Name0"), ABC1(1, "Name1"), ABC2(2, "Name2"), ABC3(3, "Name3"); public int id; public String name; private Framework (int id, String name){
public enum Framework {
ABC0(0, "Name0"),
ABC1(1, "Name1"),
ABC2(2, "Name2"),
ABC3(3, "Name3");
public int id;
public String name;
private Framework (int id, String name){
this.id = id;
this.name = name;
}
}
在模型类中,我有一个字段:
private int frameworkId;
谢谢你我想出来了——很简单 我在控制器类中将框架的值传递给窗体:
model.addAttribute("frameworks", Framework.values());
然后:
框架: