How to disable spring form?

In my jsp for certain conditions, I want the flag to be present, but I don't want the user to be able to check it or uncheck it.

I am not sure how I can achieve this. I tried the following

<form:checkbox path="..." disabled = "disabled"> <form:checkbox path="..." disabled = "true"> <form:checkbox path="..." readonly = "readonly"> 

Nothing is working.

Can someone shed some light on this?

Thanks..

+7
source share
1 answer
Attribute

disabled in <spring:checkbox> must be set to true or false , and the flag does not have a readonly attribute. So,

 <form:checkbox path="corespondingPath" disabled = "true"> 

must work.

Some links
Spring link to doc.
Readonly and Disabled property in Spring

You can use JSTL to add it depending on some condition

 <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> 
+18
source

All Articles