What does the scope attribute from the action tag of the struts-config file mean?
Asked Answered
I

2

7

I'm working on a Struts application.

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.

<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?

Ibadan answered 21/2, 2013 at 9:21 Comment(0)
O
8

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.

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.

You can check this reference to determine how to use scopes.

There's also link to action mapping configuration.

Overarm answered 21/2, 2013 at 13:30 Comment(1)
(With the caveat that in the context of the question only "request" and "session" scopes are useful.)Soracco
S
2

It determines if the ActionForm is in the request or session.

Soracco answered 21/2, 2013 at 12:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.