首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

<c:if>标签,单选按钮选中的有关问题

2012-05-22 
c:if标签,单选按钮选中的问题。HTML codec:if test${team.sex男}input typeradio idsex

<c:if>标签,单选按钮选中的问题。

HTML code
<c:if test="${team.sex=='男'}">                            <input type="radio" id="sex" value="男" name="team.sex" checked="checked"/> 男&nbsp;&nbsp;&nbsp;                             <input type="radio" id="sex1" value="女" name="team.sex" /> 女                             </c:if>                            <c:if test="${team.sex=='女'}">                            <input type="radio" id="sex" value="男" name="team.sex"/> 男&nbsp;&nbsp;&nbsp;                             <input type="radio" id="sex1" value="女" name="team.sex" checked="checked"/> 女                             </c:if>



我这是一个编辑页面,
想要的是,如果从数据库里面查询的值是男,则编辑页面性别那块选中 男,
如果是女,则编辑页面显示女

但是我这样写之后,页面一个都没有选中呢,
这是为什么呢~

[解决办法]
Java code
<input type="radio" id="sex" value="男" name="team.sex" <%=request.getAttribute("team.sex") != null && request.getAttribute("team.sex").toString().equals("男")?"checked":""%>/> 男&nbsp;&nbsp;&nbsp;         <input type="radio" id="sex1" value="女" name="team.sex" <%=request.getAttribute("team.sex") != null && request.getAttribute("team.sex").toString().equals("女")?"checked":""%> /> 女
[解决办法]
LZ 怎么还在纠结哦 都说了在el里面 == 是和后台比较是一个意思,比较内存地址不是表面值,要比较表面值是用 eq 这个来比较 快去试试吧

热点排行