0

我有jsp中的代码;以下代码在 ac:forEach 循环内。

 <td>
        <form:radiobutton  path="status" value="true"  class="radio onRadio" />
           <label class="lblOn">On</label>
        <form:radiobutton  path="status" value="false"  class="radio offRadio" />
           <label class="lblOff">Off</label>
    </td>

在我的 pojo 中,属性是:

public Class Channel{
    private boolean status= false;
 ......
}

和 getter 和 setter

serviceImpl 就像:

 Channel oChannel = new Channel();

    /* active/inactive will comes from DB */

    if("active".equalsIgnoreCase("active")){
        oChannel.setStatus(true);
    }else{
        oChannel.setStatus(false);
    }

但是在jsp中,我正在为所有行选择Off,我在哪里做错了?有什么帮助吗?

4

2 回答 2

0

尝试在服务中进行此更改,因为 get("status") 将是您单选按钮的值,并且您使用“活动”进行检查。“活跃”从何而来?

if("active".equalsIgnoreCase(map.get("status").toString()))

if("true".equalsIgnoreCase(map.get("status").toString()))

于 2013-10-30T09:59:09.317 回答
0

暂时得到一个讨厌的解决方案:

<td>
  <c:choose>
    <c:when test="${status == 'true'}">
      <input type="radio" id="chStatusId" name="status" value="true" checked="checked"/>
      <label class="lblActive">Active</label>
      <input type="radio" id="chStatusId" name="status" value="false"/>
      <label class="lblInactive">Inactive</label>
    </c:when>
    <c:when test="${status == 'false'}">
      <input type="radio" id="chStatusId" name="status" value="true" />
      <label class="lblActive">Active</label>
      <input type="radio" id="chStatusId" name="status" value="false" checked="checked"/>
      <label class="lblInactive">Inactive</label>
   </c:when>
</c:choose> 
</td>
于 2013-10-30T12:20:31.500 回答