我一直在为此寻找一个具体的答案,因为大部分谷歌都返回了很多非常古老的帖子。这是greetingActionForm
在请求范围内,还是在 session 范围内?除了action
还有什么位置吗?和 form-bean
声明来确定表单的范围?
<action-mappings>
<action path="/hello/my/oldfriend"
type="com.imFine.HowAreYouAction"
name="greetingActionForm"
validate="true"
input="/the/front/door">
<forward name="success" path="/go/get/drinks.do" />
</action>
</action-mappings>
<form-beans>
<form-bean name="greetingActionForm" type="com.forms.GreetingActionForm"/>
</form-beans>
最佳答案
如果未指定,默认情况下 ActionForm 的范围为 session
.
ActionForm 的范围在 <action>
中指定。配置为属性 scope
.您可以在 Struts DTD 中找到它。 :
The "action" element describes an ActionMapping object that is to be used
to process a request for a specific module-relative URI. The following
attributes are defined:
.....
.....
scope The context ("request" or "session") that is used to
access our ActionForm bean, if any. Optional if "name" is
specified, else not valid. [session]
.....
.....
此值在 org.apache.struts.config.ActionConfig 中初始化表示来自 Struts 模块配置文件的元素的配置信息的类:
/**
* <p> Identifier of the scope ("request" or "session") within which our
* form bean is accessed, if any. </p>
*/
protected String scope = "session";
关于forms - 这是 session 范围或请求范围内的 struts 1.x 表单 bean 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6795959/