首页 > 解决方案 > 问题:每个在HTML 标记。Thymeleaf 和 Spring 所以我在 Intellij idea 中做了这个简单的项目。我正在用下一个元素填充数组: public class formClass { private String list[] = {"+", "-", "x", "/"}; public String[] getList() { 返回列表;} } 这是控制器部分。这里我添加 formClass 对象作为模型属性: @Controller public class Gr

问题描述

标签: javahtmlspringthymeleaf

解决方案


尝试 th:selected 选择默认选项。

请使用以下语法

<option th:each="i : ${list}" th:value="${i}" th:text="${i}" th:selected="${ i==\"+\"" }></option>

希望这会奏效。


推荐阅读