【发布时间】:2019-05-24 17:36:58
【问题描述】:
我正在尝试将用户输入与复选框绑定。如果选中检查,变量应该为真。否则为假。在我的情况下,当用户选中复选框时,变量值为 true(如预期)但当用户未选中复选框时,我的变量绑定空值(预期为 false)。为什么不绑定false???
我已经附上了我的jsp代码。
JSP 代码
<c:forEach items="${giftDelivery.tempHistoryDto}" var="profile" varStatus="status">
<tr class="table_rows">
<td>
<input type="checkbox" name="tempHistoryDto[${status.index}].giftStatus" <c:if test="${profile.giftStatus == true}">checked = "checked"</c:if>>
</td>
</tr>
</c:forEach>
我在这里做错了什么。
任何帮助将不胜感激。
非常感谢。
【问题讨论】:
-
你为什么这样做
name="tempHistoryDto[${status.index}].giftStatus"而不是name="${profile.giftStatus)"?
标签: jsp model-view-controller data-binding jsp-tags modelattribute