2012-06-25 122 views
1

我使用Spring MVC的更新状态输入单选按钮,JSTL和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> 

感谢

回答

0

我不知道ABO这个。我希望我的回答能帮助你。试试吧。

​​
0

一个好方法是将属性放在EL表达式中,在三元if;如果条件为真,则将属性checked = checked;如果没有,什么都不做

<input type="radio" name="status" id="radio-1" value="ACTIVE" class="ck" ${userIdSearch.state eq 'ACTIVE' ? 'checked=\"checked\"' :''} /> 
0

进口java.sun.com/jstl/core_rt(我称之为 “C”,但你可以把它叫做什么):

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> 

然后你就可以使用C:如果在单选按钮,如下所示:

<input type="radio" name="status" id="radio-1" value="ACTIVE" class="ck" <c:if test="${status.value == 'ACTIVE'}">checked="checked"</c:if> />Active 

如果这仍不能绑定到你的对象,你可以尝试使用的弹簧,像这样绑定:

<%@ 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>