我使用的是spring mvc
当我创建用户时,在我的表单中激活或停用的单选按钮完美地保存在我的数据库中
当我编辑我的用户它没有选择输入单选按钮的实际状态,我需要在jslt建议,以下是我的代码
<div class="section">
<label>Status<small>status</small></label>
<div>
<div>
<input type="radio" name="status" id="radio-1" value="ACTIVE" class="ck" checked='<c:out value="${userIdSearch.state ? 'ACTIVE'}">checked</c:out>'/>
<label for="radio-1">Active</label>
<input type="radio" name="status" id="radio-2" value="DEACTIVE" class="ck" checked='<c:out value="${userIdSearch.state ? 'DEACTIVE'}">checked</c:out>'/>
<label for="radio-2">Deactive</label>
</div>
</div>
</div>提前感谢pradeep
发布于 2012-06-26 05:09:48
这一点我不太确定。我希望我的答案能帮助你试一试。
<input checked="<c:if test="${userIdSearch eq 'Active'}">checked</c:if>">发布于 2015-06-10 22:06:06
一个不错的方法是将属性放在EL表达式中的三元if中;如果条件为真,则将属性放入checked=checked;如果不为真,则不执行任何操作
<input type="radio" name="status" id="radio-1" value="ACTIVE" class="ck" ${userIdSearch.state eq 'ACTIVE' ? 'checked=\"checked\"' :''} />发布于 2016-03-03 01:20:20
Import java.sun.com/jstl/core_rt (我管它叫"c",你也可以随便叫它):
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>然后您可以在单选按钮中使用c:if,如下所示:
<input type="radio" name="status" id="radio-1" value="ACTIVE" class="ck" <c:if test="${status.value == 'ACTIVE'}">checked="checked"</c:if> />Active如果这仍然没有绑定到您的对象,您可以尝试使用spring绑定,如下所示:
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
...
<spring:bind path="pathToActive.status">
<input type="radio" name="<c:out value="${status.expression}"/>" id="radio-1" ... etc
</spring:bind>https://stackoverflow.com/questions/11197293
复制相似问题