thymeleaf 下拉选框回显选中

参考了许多,最后以这种方法实现了。尽管有些愚蠢,初步学习阶段。
不知道为什么用th:field会报错。网上有些是用field来解决回显问题的。

<select name="position" lay-verify="required">
<option th:selected="${aet.getPosition()=='助教'}" th:value="助教">助教</option>
<option th:selected="${aet.getPosition()=='讲师'}" th:value="讲师">讲师</option>
<option th:selected="${aet.getPosition()=='副教授'}" th:value="副教授">副教授</option>
<option th:selected="${aet.getPosition()=='教授'}" th:value="教授">教授</option>
</select>

猜你喜欢

转载自www.cnblogs.com/christy99cc/p/12032763.html