我将在我的theyemeleaf应用程序中添加一个select标记。代码如下:
<form th:action="@{/suggestevent}" th:object="${event}" method="post">
<div class="form-group">
<select class="form-control" name="type" th:field="*{type}">
<option value="party" th:value="party">Party</option>
<option value="Workshop" th:value="Workshop">Workshop</option>
<option value="Friendship" th:value="Friendship">Friendship</option>
</select>
</div>
</form>
我的dropbox中只有三个固定值。问题是它没有在属性type
中设置任何值。换句话说,它不起作用。
发布于 2017-10-03 18:03:27
当你使用胸腺叶和它们的属性时,比预期的要容易,然后只需要使用th:field和th:value,这两个属性默认情况下会添加属性名称和值,所以你不需要添加它。
<form th:action="@{/suggestevent}" th:object="${event}" method="post">
<div class="form-group">
<select class="form-control" th:field="*{type}">
<option th:value="party">Party</option>
<option th:value="Workshop">Workshop</option>
<option th:value="Friendship">Friendship</option>
</select>
</div>
</form>
https://stackoverflow.com/questions/46502901
复制相似问题