在進行修改操作時,首先需要根據id獲取到指定的信息,將信息通過域對象回顯到修改頁面,針對radio標簽,在thymeleaf語法中,可以使用
th:field="${emp.empSex}"
進行數據回顯,當數據的內容和radio標簽的value屬性內容一致時會自動選中。
<form th:action="@{/employee}" method="post">
<input type="hidden" name="_method" value="put">
<input type="hidden" name="id" th:value="${emp.id}">
姓名:<input type="text" name="empName" th:value="${emp.empName}"><br/>
性別:
<input type="radio" name="empSex" value="1" th:field="${emp.empSex}">男
<input type="radio" name="empSex" value="2" th:field="${emp.empSex}">女 <br/>
電話:
<input type="text" name="empPhone" th:value="${emp.empPhone}"><br/>
<input type="submit" value="修改">
</form>