这就是我填充下拉列表的方式。我认为这可能有助于你了解它。
Controller
List<Operator> operators = operatorService.getAllOperaors()model.addAttribute("operators", operators);
Model
@Entity @Table(name = "operator") public class Operator { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") @JsonIgnore private Long id; @NotBlank(message="operator Name cannot be empty") @Column(name = "operator_name", nullable = false) private String operatorName; getters and setters ...}
View
<div > <select th:field="${operator.opeId}" id="dropOperator"> <option value="0">select operator</option> <option th:each="operator : ${operators}" th:value="${operator.id}" th:text="${operator.operatorName}"></option> </select></div>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)