开发者

Spring MVC boolean/radio button default value

I am using a boolean i开发者_如何学JAVAn my Spring MVC form. However, when the form first displayed the boolean defaults to false. I want the boolean to be initialized to something equivalent to null, and stay that way until the user makes their choice.

Any suggestions? Thanks for the help.

FYI: I don't want to use checkbox, or anything else. I would really prefer a radio button.

<springform:form>
    <springform:radiobutton value="1" />
    <springform:radiobutton value="0" />
<springform:form>


one way to solve this is using Boolean class instead of boolean primitive. Boolean class has a default value of null so it is not initially set.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜