Amit, et al.
I'm going to assume you're extending the SimpleFormController class. I'm not sure you can set the default value with the <form:checkbox path="booleanValue" /> JSP tag. Historically speaking, I've found it best to override the protected Object formBackingObject(HttpServletRequest request) method to setup the form object to be used before actually rendering the form. If you do not override this method, the command object that gets returned is effectively new MyCommandObject() meaning the default values are taken from the default constructor of your command object.
To set the default value, you should properly initialize your form backing object and set the appropriate default values. This should look something like the following snippet:
Code:
public class MySimpleFormController extends SimpleFormController {
...
@Override
protected Object formBackingObject(HttpServletRequest request)
throws Exception {
MyFormCommand command = new MyFormCommand();
...
command.setBooleanValue(true);
...
return command;
}
}
When the form gets rendered, the booleanValue is true which results in the checkbox being checked by default.
Alternatively, you can set default values in the default constructor of the command object; although I do not recommend this approach as each form controller may have different requirements for the default values of a command object. Going this route often discourages good code reuse techniques.
Hope that helps,
Joshua Preston.