OGNL

  1. OGNL
    1.1 OGNL的全称是Object Graph Navigation Language(对象图导航语言),它是一种强大的表达式语言
    1.2 OgnlContext(ongl上下文)其实就是Map<String,Object>
    OgnlContext=根对象(1)+非根对象(N)
    非根对象要通过"#key"访问,根对象可以省略"#key"

    注1:context:英文原意上下文,环境/容器
    1.3 把根对象和非根对象说出来

  2. ValueStack
    2.1 值栈
    先进后出的数据结构,弹夹 push/pop
    2.2 为什么要使用ValueStack作为根对象
    放到值栈中的对象都可视为根对象
    employ
    manager name
    student name

for(String s:ctx){
if(name){
break;
}
}

ctx.put(“employ”,employ);---------2
ctx.put(“manager”,manager);------1
ctx.put(“student”,student)---------0

从小到大
page -> request -> session -> application

从上至下
A
B
C
D

//struts2的工作流程
//伪代码
*.action
3. ActionContext
3.1 ActionContext ac = ActionContext.getContext();//保证同一请求中只创建一个上下文
request
session
application
parameters
ValueStack(root)

3.2 向ValueStack压栈
ValueStack vs = ac.getValueStack();
vs.push(XxxAction)//studentAction
vs.push(ModelDirver.getModel())//model不为null student

3.3 Map<String,String[]> map = request.getParamterMap();
//参数名==OGNL表达式
{“userName”:“zs”,“sid”:18,“sex”:“F”}

  setValue("userName", ac, vs, "zzz");
  setValue("uname", ac, vs, "kfc");
  setValue("upwd", ac, vs, "999");
  setValue("age", ac, vs, "17");


student                [0]
 studentAction    [1]
  1. struts2中传递数据
    可以使用作用域,但更多的是利用ValueStack或ActionContext(ognl)

在这里插入图片描述
这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值