`
yanglei008
  • 浏览: 85723 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

spring bind checkbox 传递值问题

阅读更多
Single Checkbox
Note that the hidden field is neccessary to bind when the checkbox is unchecked.
       <spring:bind path="command.myBooleanProperty"> 
          <input type="hidden" name="_<c:out value="${status.expression}"/>">
          <input type="checkbox" name="<c:out value="${status.expression}"/>" value="true"
              <c:if test="${status.value}">checked</c:if>/>
       </spring:bind>
     </c:forEach>

Multiple Checkboxes
One way of binding multiple checkboxes is to create a child array where its objects have a boolean flag to indicate selected status.

  
 <c:forEach items="${command.childArray}" var="child" varStatus="loopStatus">
       <spring:bind path="command.childArray[${loopStatus.index}].selected"> 
          <input type="hidden" name="_<c:out value="${status.expression}"/>">
          <input type="checkbox" name="<c:out value="${status.expression}"/>" value="true"
              <c:if test="${status.value}">checked</c:if>/>
       </spring:bind>
     </c:forEach>
分享到:
评论
1 楼 fishoflove 2009-06-09  
多谢 问题解决了

相关推荐

Global site tag (gtag.js) - Google Analytics