关于Struts2的ONGL与ValueStack的解读

The framework uses a standard naming context to evaluate OGNL expressions. The top level object dealing with OGNL is a Map (usually referred as a context map or context). OGNL has a notion of there being a root (or default) object within the context. In expression, the properties of the root object can be referenced without any special "marker" notion. References to other objects are marked with a pound sign (#).

   这个框架【Struts2】用一个标准的命名上下文评价OGNL表达式。处理ONGL顶层对象是一个Map集合(通常指的是一个上下文map或者上下文)

   ONGL有一个概念是在上下文中存在一个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).

    框架将设置OGNL上下文为我们ActionContext,并且值栈被设置为OGNL根对象。(值栈加入多个对象,但ONGL对外呈现一个对象)。

   与值栈一起,框架放置了其他对象在ActionContext中,包括表示引用程序的Maps,session和request Context.这些对象共存在ActionContext中,与值栈一起(我们OGNL根)

The Action instance is always pushed onto the value stack. Because the Action is on the stack, and the stack is the OGNL root, references to Action properties can omit the # marker. But, to access other objects in the ActionContext, we must use the # notation so OGNL knows not to look in the root object, but for some other object in the ActionContext.

     Action实例通常被推送值栈上。因为Action是在栈中,并栈是在OGNL根,引用Action属性可以省略#。但是在ActionContext中访问其他对象,我们必须使用#,这样的话OGNL会知道不查询ROOT对象,会去查询其他的对象在ActionContext.

                     |--application
                     |
                     |--session
       context map---|
                     |--value stack(root)
                     |
                     |--action (the current action)
                     |
                     |--request
                     |
                     |--parameters
                     |
                     |--attr (searches page, request, session, then application scopes)
                     |

转载于:https://www.cnblogs.com/flytogalaxy/p/7777082.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值