值栈里面有值:
以下代码:OGNL没取值栈没问题,EL却有问题
${message}
<s:property value="message"/>
<s:debug></s:debug>
显示如下:
${message} WHY
[Debug]
Struts ValueStack Debug
Value Stack Contents
Object Property Name Property Value
com.itcast.test.HelloAction texts null
message WHY
actionErrors []
errors {}
fieldErrors {}
errorMessages []
locale zh_CN
actionMessages []
com.opensymphony.xwork2.DefaultTextProvider texts null
首先:
值栈(根)对象也可以直接使用EL表达式访问,原因是struts2对HttpServletRequet进行了一次封装,封装的代码主要是重写了getAttribute方法,简述重写此方法的核心代码:首先在原始的HttpServletRequest对象中查找el表达式中的属性,如果找不到再通过ActionContext获取值栈对象,进而再从值栈对象中查找el表达式中要访问的属性。
其次看下你的项目是否支持EL 表达式!