可以使用两个单选标签为struts中的表单属性设置布尔值吗?
我对 struts 还很陌生,而且我特别陷入与单选按钮有关的 struts 代码区域。无论我做什么,我只能从以下代码中得到一个错误值: (CostForm)
<td align="left" width="200px" colspan="2">
<html:radio property="responsableBool" value="false"/>No
<html:radio property="responsableBool" value="true"/>Yes
</td>
然后从这段代码初始化:
CostForm costform = (CostForm) form;
Cost cost = new Cost();
costform.populateModel(cost);
并且 populateModel 只有: PropertyUtils.copyProperties(cost,this);
我唯一能想到的是struts 不允许单选按钮引用具有不同值的相同属性。
I'm new-ish to struts and I'm particularly stuck on an area of struts code which has to do with the radio button. No matter what I do I can't get anything but a false value from the following: (CostForm)
<td align="left" width="200px" colspan="2">
<html:radio property="responsableBool" value="false"/>No
<html:radio property="responsableBool" value="true"/>Yes
</td>
It is then initialised from this piece of code:
CostForm costform = (CostForm) form;
Cost cost = new Cost();
costform.populateModel(cost);
and the populateModel just has: PropertyUtils.copyProperties(cost,this);
The only thing I can think of is that struts doesn't allow the radio buttons to reference the same property with different values.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
给定形式:
HTML:
操作:
当我单击“否”和“是”时,我会在操作中获得预期的布尔值。
我会仔细检查拼写(英文拼写是“responsible”;也许在
Cost
中拼写正确?)、动作/形式不匹配(您是否在中使用了正确的形式“name”)动作映射?),等等。Given the form:
The HTML:
The action:
When I click "No" and "Yes" I get the expected boolean value inside the action.
I'd double-check things like spelling (the English spelling would be "responsible"; perhaps it's spelled correctly in
Cost
?), action/form mismatches (are you using the right form "name" in the action mapping?), and so on.