我尝试将selected放到空选项内,并且在th:text之后加上th:select,但对我都不起作用,这是我的代码:
<select name="uploadDate"style=" width:100%;" id="uploadDate" class="form-control select2">
<option></option>
<option th:each="uploadDateMenu : ${uploadDateMenu.entrySet()}"
th:value="${uploadDateMenu.key}"
th:text="${uploadDateMenu.value}">
</option>
</select>
我尝试放置代码:
th:selected="${uploadDateMenu.key == 2}"
在选项标签内的“ th:text”之后,但不起作用。数据在键值对中。密钥为2且与之对应的值为“过去2天”。
尝试: