java struts-config 文件的 action 标签中的 scope 属性是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14998510/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does the scope attribute from the action tag of the struts-config file mean?
提问by marlieg
I'm working on a Struts application.
我正在开发一个 Struts 应用程序。
In order to edit the struts-config.xml
file, I think I have to add an attribute - scope
, in the action tag. I'm not sure about its meaning, or its usage.
为了编辑struts-config.xml
文件,我想我必须scope
在动作标签中添加一个属性 - 。我不确定它的含义或用法。
<action path="/WetsVpnSwapTraffic"
type="com.kpn.bop.web.action.vpn.wets.WetsVpnSwapTraffic"
scope="request"
name="WetsVpnSwapTrafficForm"
roles="bop_wetsvpn_migrate"
validate="false">
<forward name="success" path="/WetsVpnSwapTrafficValidate.do"/>
<forward name="failure" path="/WetsVpnList.do"/>
</action>
Can anyone explain me if I have to put this attribute?
如果我必须放置此属性,谁能解释一下?
回答by Roman C
The attribute scope
is used to define the scope (life of the object, the form) of the object action form that used in that action configuration.
该属性scope
用于定义在该操作配置中使用的对象操作表单的范围(对象的生命周期、表单)。
There's also different scopes, page
, request
, session
, application
. That's all from servlet specs. If you specify the scope of request that you want the form object is available during servlet http request.
还有不同的范围,page
, request
, session
, application
。这一切都来自 servlet 规范。如果您指定请求的范围,您希望表单对象在 servlet http 请求期间可用。
You can check this referenceto determine how to use scopes.
您可以查看此参考资料以确定如何使用范围。
There's also link to action mapping configuration.
还有指向操作映射配置的链接。
回答by Dave Newton
It determines if the ActionForm
is in the request or session.
它确定 是否ActionForm
在请求或会话中。