怎么样用springmvc对表单radio chexbox select 把这些标签的数据存到数据库 而且在点

J2EE 码拜 7年前 (2017-04-19) 1124次浏览
怎么样用springmvc对表单radio  chexbox  select 把这些标签的数据存到数据库   而且在点击功能的时候数据还能对应的radio  chexbox  select标签还能回显数据    大家springmvc项目怎么做的呢
解决方案

30

public class User{
    private String name;
    private Gender gender;//性别
    private Boolean forbidden;//禁止/锁定
    private List<Role> roles;//角色
}

//jsp

<form:form modelAttribute="user" method="post" action="...">
<!--radio-->
<form:radiobutton path="gender" value="famale" label="女"/>
<form:radiobutton path="gender" value="male" label="男"/>
<!--select-->
<form:select path="role">
<form:option value="nomal" label="普通用户"/>
<form:option value="admin" label="管理员"/>
</form:select>
<!--checkbox-->
<form:checkbox path="forbidden" value="true" label="禁止使用"/>
</form:form>

使用Spring form表单标签就能自动回显。


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明怎么样用springmvc对表单radio chexbox select 把这些标签的数据存到数据库 而且在点
喜欢 (0)
[1034331897@qq.com]
分享 (0)