是否将为每个新的操作对象创建一个新的ActionContext和ValueStack? [英] Will a new ActionContext and ValueStack be created for every new action object?

查看:92
本文介绍了是否将为每个新的操作对象创建一个新的ActionContext和ValueStack?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是:

1)在Struts2中,每个动作对象是否都有自己对应的ActionContextValueStack?

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

换句话说,对于每个新请求,都会创建一个新的操作对象.这是否意味着每次创建新的动作对象时,也会同时创建新的ActionContextValueStack?

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)考虑这种情况:

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

因此,当请求action1时,将创建action1的新对象以及相应的ActionContextValueStack.

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

在view.jsp中(单击超链接时),有一个新的请求将请求action2.

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

这是否意味着先前的ActionContextValueStack(与action1相关)被破坏,并且创建了新的ActionContextValueStack(对于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)假设我将某些内容存储在view.jsp的ActionContext(action1的)中,然后单击action2的超链接(来自view.jsp),该数据和ActionContext(action1的)一起会丢失?

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?

谢谢.

推荐答案

为每个请求创建一个新的ActionContextValueStack.这通常意味着每个动作,但并非总是如此(在动作链接的情况下).这些按请求的对象在请求结束时超出范围.然后,您存储在其中的所有内容都将消失.

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.

这篇关于是否将为每个新的操作对象创建一个新的ActionContext和ValueStack?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆