struts-config.xml 文件的action 元素中的scope 属性有多少个可用值
有多少个值可用于“action”元素中的“scope”属性 struts-config.xml
文件除了“request”和“session”之外?
<action name="loginform" path="/bkplogin" scope="?" type="org.springframework.web.struts.DelegatingActionProxy">
How many values available for "scope" attribute in "action" element ofstruts-config.xml
file other than "request" and "session"?
<action name="loginform" path="/bkplogin" scope="?" type="org.springframework.web.struts.DelegatingActionProxy">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作用域属性只有两个可能的值:请求和会话,如struts-config的DTD中所述:
请参阅此处的DTD:< br>
http://struts.apache.org/dtds/struts-config_1_3.dtd
或者这里有更易于阅读的 DTD 文档:
http://struts.apache.org/1 .x/struts-core/dtddoc/struts-config_1_3.dtd#action
那么,跨 JSP 页面的对象范围可以是:
现在,struts-config 中的范围指的是创建/查找 ActionForm 对象的位置。 ActionForm 代表客户端 HTML 表单的服务器对象表示。
拥有具有应用范围的表格没有任何意义,因为它将是适合每个人的一种表格,我什至无法想象它会有什么用处。所以该领域没有应用价值。
现在假设您有页面范围。这将如何运作? Struts 执行 RequestDispatcher.forward/redirect 转到JSP 文件,如何将 ActionForm 保存在仍然没有页面范围的页面的页面范围中,因为它还没有控制权?!就像向方法发送值一样,但您不是发送方法参数,而是尝试从方法外部直接在方法代码中创建局部变量。
因此只有两个值有意义:请求和会话。如果你想要额外的东西,你必须自己管理。
Struts 是一个通用框架,它并没有涵盖所有可以想象或难以想象的情况,它涵盖了大多数正常用例场景,其中请求和会话就是您所需要的。
There are only two possible values for the scope attribute: request and session as stated in the struts-config’s DTD:
See the DTD here:
http://struts.apache.org/dtds/struts-config_1_3.dtd
or a more human readable documentation of the DTD here:
http://struts.apache.org/1.x/struts-core/dtddoc/struts-config_1_3.dtd#action
Well, the scope of an object across JSP pages can be:
Now, the scope in struts-config refers to where to create/find ActionForm objects. An ActionForm represents the server object representation of a client HTML form.
It does not make any sense to have the form with application scope because it will be one form for everybody which which I can't even think at what that will be useful. So no application value for that field.
Now imagine you have page scope. How will that work? Struts does a RequestDispatcher.forward/redirect to go to the JSP files, how is it going to save the ActionForm in the page scope of the page that still does not have a page scope since it does not yet have control?! Is just like sending values to a method but instead of sending method arguments you are trying to directly create local variables in the code of the method from outside the method.
So there are only two values that make sense: request and session. If you want something extra you have to manage it yourself.
Struts is a generic framework, it does not cover every imaginable or unimaginable case, it covers most of normal use case scenarios for which request and session is all you will ever need.