在我的jsp中,对于某些条件,我希望复选框存在但不希望允许用户检查或取消选中它. 我不确定如何实现这一目标.我尝试了以下内容 form:checkbox path="..." disabled = "disabled" form:checkbox path="..
我不确定如何实现这一目标.我尝试了以下内容
<form:checkbox path="..." disabled = "disabled"> <form:checkbox path="..." disabled = "true"> <form:checkbox path="..." readonly = "readonly">
似乎没什么用.
有人可以对此有所了解吗?
谢谢..
< spring:checkbox>中的禁用属性应设置为true或false,复选框不具有readonly属性.所以<form:checkbox path="corespondingPath" disabled = "true">
应该管用.
几个链接
Spring doc link.
Readonly and Disabled property in Spring form input
您可以根据某些条件使用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>
