Will a new ActionContext and ValueStack be created

2019-08-15 03:57发布

问题:

My questions are:

1) In Struts2, does every action object have its own corresponding ActionContext and ValueStack?

In other words, for every new request a new action object is created. Does this mean every time a new action object is created, a new ActionContext and ValueStack also get created?

2) Consider this scenario:

Action1------1st req------->view.jsp------2nd req--------->action2

So when a request comes for action1 a new object of action1 and corresponding ActionContext and ValueStack will get created.

From view.jsp (upon clicking hyperlink) a new request goes for action2.

Does this mean that previous ActionContext and ValueStack (related to action1) gets destroyed and a new ActionContext and ValueStack (for action2) gets created?

3) Suppose I store something in ActionContext (of action1) in view.jsp and then click on hyperlink for action2 (from view.jsp), will that data along with the ActionContext (of action1) get lost?

Thanks.

回答1:

A new ActionContext and ValueStack are created for each request. This usually means for each action, but not always (in the case of action chaining). These per-request objects fall out of scope at the end of the request. Anything you store in them is then gone at that point.