java sprmvc radio 性别更新

java sprmvc 后台数据显示到jsp页面,要进f行更新,用到了radio,

由于需要进行更改后还要插入数据库,所欲费了好大一番功夫

终于搞定

这是第一种方法:

<input type="radio" <c:if test="${user.sex == '1}"> <c:out value="checked"/> </c:if> name="sex" value="1" />男
<input type="radio" <c:if test="${user.sex == '2}"> <c:out value="checked"/> </c:if> name="sex" value="1" />女
第二种方法

<c:if test="${info.sex=='1'}">
<input type="radio" name="sex" checked="checked" value="1"/>男
<input type="radio" name="sex" value="0"/>女
</c:if>

<c:if test="${sex=='0'}">
<input type="radio" name="sex" value="1"/>男
<input type="radio" name="sex" checked="checked" value="0"/>女
</c:if>
第三种方式

<input type="radio" name="sex" value="1" checked="${info.sex=='1'?"'checked'":''}"/>男
<input type="radio" name="sex" value="1" checked="${info.sex==0?"'checked'":''}"/>女

第四中方式

<input type="radio" name="emp.sex" value="1" <c:if test="${sex=='1'}" 'checked'/>/>男
<input type="radio" name="emp.sex" value="1" <c:if test="${sex=='0'}" 'checked'/>/>女
亲测第一种有效,第二三种没有效果,我用的是mysql的数据库,int类型存储数据,后几种引用自博客http://blog.csdn.net/elmo66/article/details/51107650

他用的是oracle,文中 说跟其中存储数据类型有关。以后用到了再研究吧


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值