What's the purpose of storing objects directly to the ValueStack/ActionContext?

前端 未结 1 1126
灰色年华
灰色年华 2021-01-29 00:09

Based from what I\'ve researched, I\'ve seen that tags such as , or by creating an are able to

相关标签:
1条回答
  • 2021-01-29 00:26

    Every place has its dedicated storage where you can put your objects for later use/retrieve running across some invocation context. Whatever context is running the framework is associated. The context is the way of communicating between scoped objects inside it you can access using Java or other expression language (EL) like OGNL.

    In OGNL the action context is the OGNL context, and the value stack is a root.

    The framework sets the OGNL context to be our ActionContext, and the value stack to be the OGNL root object. (The value stack is a set of several objects, but to OGNL it appears to be a single object.) Along with the value stack, the framework places other objects in the ActionContext, including Maps representing the application, session, and request contexts. These objects coexist in the ActionContext, alongside the value stack (our OGNL root).

    The ActionContext is ThreadLocal, so you can use it in one thread. The best way to get the action context/value stack from this thread is using static method.

    ActionContxt ctx = ActionContext.getContext();
    ValueStack vs = ctx.getValueStack();
    

    Interceptors also have a parameter passed, known as invocation context, which is the action context.

    The value stack has also its own context, the validation has its own context. So, these definitions never end.

    0 讨论(0)
提交回复
热议问题