Struts2中EL表达式的取值顺序及OGNL表达式的取值顺序
来源:互联网 发布:淘宝女装top1 编辑:程序博客网 时间:2024/05/16 15:16
好记性不如赖笔头…………
正常EL的查找域为:page(PageContext)–>request–>session–>application
Struts2中EL的查找域为:page(PageContext)–>request–>contextMap–>ValueStack–>session–>application
有的人说Struts2中EL的取值顺序是:page(PageContext)–>request–>ValueStack–>contextMap–>session–>application,
但查看源码(org.apache.struts2.dispatcher.StrutsRequestWrapper)发现request中的取值顺序如下:
public Object getAttribute(String key) { if (key == null) { throw new NullPointerException("You must specify a key value"); } if (disableRequestAttributeValueStackLookup || key.startsWith("javax.servlet")) { // don't bother with the standard javax.servlet attributes, we can short-circuit this // see WW-953 and the forums post linked in that issue for more info return super.getAttribute(key); } **//注意,这里是先查找的actionContext中的contextMap的内容** ActionContext ctx = ActionContext.getContext(); Object attribute = super.getAttribute(key); if (ctx != null && attribute == null) { boolean alreadyIn = isTrue((Boolean) ctx.get(REQUEST_WRAPPER_GET_ATTRIBUTE)); // note: we don't let # come through or else a request for // #attr.foo or #request.foo could cause an endless loop if (!alreadyIn && !key.contains("#")) { try { // If not found, then try the ValueStack ctx.put(REQUEST_WRAPPER_GET_ATTRIBUTE, Boolean.TRUE); **//最后,如果request、contextMap都没有,才去的valueStacK去查找** ValueStack stack = ctx.getValueStack(); if (stack != null) { attribute = stack.findValue(key); } } finally { ctx.put(REQUEST_WRAPPER_GET_ATTRIBUTE, Boolean.FALSE); } } } return attribute; }
OGNL的查找域为:page(PageContext)–>ValueStack–>contextMap–>request–>session–>application
阅读全文
0 0
- Struts2中EL表达式的取值顺序及OGNL表达式的取值顺序
- el表达式取值顺序
- el表达式取值顺序
- 关于struts2中使用OGNL表达式取值,取不到值的原因及解决方法
- Struts2中EL表达式的取值范围问题
- Struts2的ognl与JSP的el表达式取值问题
- Struts2中EL表达式取值
- Struts2中EL表达式取值
- JSP中EL表达式的取值
- EL表达式与ognl表达式对Map的key为Integer时的取值,Ognl表达式比较友好
- el表达式跟ognl表达式的区别(用法和页面取值)
- el表达式跟ognl表达式的区别(用法和页面取值)
- el表达式跟ognl表达式的区别(用法和页面取值)
- el表达式跟ognl表达式的区别(用法和页面取值)
- el表达式跟ognl表达式的区别(用法和页面取值)
- el表达式跟ognl表达式的区别(用法和页面取值)
- el表达式和ognl表达式如何取值
- 函数操作el表达式的取值
- js对 select 的各种处理
- 在mac上通过terminal检查URL是否满足苹果ATS要求
- JavaWeb 解决超链接参数中文乱码问题
- CoAP学习笔记——CoAP格式详解
- scala把序列分解成子集(group by,partition)
- Struts2中EL表达式的取值顺序及OGNL表达式的取值顺序
- [较难] UVa OJ 714 Copying books
- Android 高清加载巨图方案 拒绝压缩图片
- SOFT_START and HOLD_AUTO_START方式
- 笔记--事件
- oracle 180天后的问题
- vivado与modelsim的联合仿真(二)
- Linux下Anaconda安装tensorflow-gpu
- iOS开发:开发过程中单例模式的使用