Will a new ActionContext and ValueStack be created for every new action object?

强颜欢笑 提交于 2019-12-13 00:57:39

问题


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.



来源:https://stackoverflow.com/questions/7545166/will-a-new-actioncontext-and-valuestack-be-created-for-every-new-action-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!