forms - 这是 session 范围或请求范围内的 struts 1.x 表单 bean 吗?

标签 forms scope struts-1 struts-config

我一直在为此寻找一个具体的答案,因为大部分谷歌都返回了很多非常古老的帖子。这是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/

相关文章:

javascript - angularjs 形成 'has-success' 标记,无需输入任何数据

javascript - 将 javascript 作用域传递给函数

php - Symfony2 : Change dropdown values based on another field value

forms - 为什么 ngModel 不读取我的表单输入? ( Angular 2/4)

javascript - 使用 Backbone.js 是否需要使用表单标签?

PHP 回调函数和变量引用

javascript - angularjs foreach循环通过依赖于先前请求的http请求

java - 在 struts 1.3 中如何从数据库中检索数据并使用 DAO 显示它

spring - Spring MVC 和 Spring Core 的区别

javascript - jsp中Select框处理一百万条记录的最佳方式