开发者

is this struts 1.x form bean in session scope or request scope?

I have been searching for a concrete answer for this, as much of google returns a lot of very old posts. Is this greetingActionForm in the request scope, or in the session scope? Is there any location besides the action and form-bean declaration to determine a form's scope?

<action-mappings>
    <action path="/hello/my/oldfriend"
            type="com.imFine.HowAreYouAction"
            name="greetingActionForm"
            validate="tru开发者_开发知识库e"
            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>


If unspecified, by default an ActionForm will have scope session.

The scope of an ActionForm is specified on the <action> configuration as attribute scope. You can find this in the 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]
     .....
     .....

This value is initialized in the org.apache.struts.config.ActionConfig class which represents the configuration information of an element from a Struts module configuration file:

/**
 * <p> Identifier of the scope ("request" or "session") within which our
 * form bean is accessed, if any. </p>
 */
protected String scope = "session";
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜