radio标签数据回显


在进行修改操作时,首先需要根据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>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM