我使用的是JAVA STRUTS。我有一个html表单,其中有一个与之关联的ActionForm类,控件是使用标记创建的。据我所知,STRUTS将持久化html表单上的选择,即使表单被刷新。我需要防止这种行为,并强制它重新绑定来自ActionForm对象的值。
基本上,我有一个带有单选按钮组的表单,允许用户选择A、B或C。我有一个ActionForm,它在加载表单时设置了属性"selection = A“。如果用户选择B并提交它,则表单被正确设置为"selection = B“,一切正常。然而,当我刷新页面时,选择被重置为“ActionForm = A”(通过调试确认),但是单选按钮选择了B!
有人知道这是为什么吗,或者我如何才能阻止它的发生?
发布于 2013-01-18 07:19:02
关于你的帖子,我以为是属于struts2
的,所以,
According to struts2 it is not possible means, you have to give the static value or you have to make in programmatic manner through JPA (or)your java code
。
对于JPA,您可以参考此链接,这对JPA way很有帮助。
This explanation is refer to static way
首先,在jsp页面中,您必须通过taglib uri
进行import struts2 tags
,然后它会显示那些您必须选择struts2的标记中的可用<s:radio></s:radio> tag
标记。
eg:
<s:radio label="Selections" name="your name" list="#{'A':'A','B':'B'}" value="2" />
在这段代码中,我输入的值是2,所以如果你去掉这个值,它会选择B作为默认值,它不会选择任何默认值。
Basically what i am trying to say here is without value it won't select any radio buttons
you have to give value through static way or dynamic way.
对于动态方式,您可以参考此链接dynamic radio button
https://stackoverflow.com/questions/14389739
复制相似问题