在我的JSP中,对于某些条件,我希望复选框存在,但不希望用户能够选择或取消选中。
我不确定如何实现这一点。我尝试了以下方法:
<form:checkbox path="..." disabled = "disabled">
<form:checkbox path="..." disabled = "true">
<form:checkbox path="..." readonly = "readonly">
似乎什么都不起作用。
有人能为此提供一些启示吗?
谢谢..
<spring:checkbox>
中的 disabled
属性应该设置为 true
或 false
,复选框没有 readonly
属性。因此,
<form:checkbox path="corespondingPath" disabled = "true">
应该可以工作。
一些链接
Spring文档链接。
在Spring表单输入中使用只读和禁用属性
您可以使用JSTL根据某些条件添加它。
<c:choose>
<c:when test="${condition}">
// Add checkbox with disabled="true"
<form:checkbox path="desiredPAth" disabled="true" />
</c:when>
<c:otherwise>
// Do something else
</c:otherwise>
</c:choose>