Struts2中EL表达式
来源:互联网 发布:邦银金租 知乎 编辑:程序博客网 时间:2024/05/21 14:47
传统
jsp中,例如${person}
,那么搜索顺序page-request-session-application
,依次调用getAttribute(String key)方法
Struts2中
由于是action转到result视图,所以page一般用不到,但是其request的搜索有变化,先看Request(StrutsRequestWrapper)本身的getAttribute()方法:
“`
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 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); ValueStack stack = ctx.getValueStack(); if (stack != null) { **attribute = stack.findValue(key);** } } finally { ctx.put(REQUEST_WRAPPER_GET_ATTRIBUTE, Boolean.FALSE); } } } return attribute;}
``可以看到,在request中搜索不到时,会调用ValueStack的findValue(key)方法。
${person}
故的搜索顺序如下:
request-ValueStack.findValue()-session-application`
(只有request发生变化,其他不变)
阅读全文
0 0
- struts2中EL表达式
- Struts2中EL表达式
- 关于struts2标签中使用el表达式
- Struts2中EL表达式取值
- Struts2中EL表达式取值
- struts2学习笔记 -- day08 Struts2中使用EL表达式
- 解决struts2框架jsp中el表达式失效
- Struts2中EL表达式的取值范围问题
- struts2学习 EL表达式总结
- el表达式 分页 Struts2后台
- struts2的EL表达式和Ognl表达式
- J2EE中EL表达式
- jsp中EL表达式
- Jsp中EL表达式
- J2EE中EL表达式
- J2EE中EL表达式
- JavaEE中EL表达式
- Struts2中EL表达式的取值顺序及OGNL表达式的取值顺序
- 51nod 1407
- Xcode9学习笔记11
- 085 定积分应用之元素法
- 容器中使用iptables报错can't initialize iptables table Permission denied (you must be root)
- 深蓝的大修&现代化改装:BST之splay tree
- Struts2中EL表达式
- 【笔记】字符串的最小表示法
- bzoj 4898: [Apio2017]商旅
- HDU
- 单调栈及应用
- 设计模式--简单工厂设计模式
- Xcode9学习笔记12
- groupByKey与reduceByKey区别
- JSP转译成Servlet详细过程