struts 2.1.2 ognl 无法调用静态方法

最近在做一个框架,用得是struts2.1.2 + proxool + iBatis
然后想在页面中得到当前时间的毫秒数,也就是 System.currentTimeMillis();
 
用ognl的静态调用
<s:property value="%{@java.lang.System@currentTimeMillis()}" />
来显示,发现结果集为空.查了好多资料都发现这个是正确的引用,困惑......
 
最后在查struts2.1.2的文档时发现struts2.1.2中加了很多配置元素,其中有一个名为struts.ognl.allowStaticMethodAccess的配置项
在文档的struts.properties的例子中:
### Whether to allow static method access in OGNL expressions or not
struts.ognl.allowStaticMethodAccess=false
 
于是把false改成true,配置到struts.properties中
struts.ognl.allowStaticMethodAccess=true
问题解决
 
也可以配置在struts.xml中
<constant name="struts.ognl.allowStaticMethodAccess" value="true" />
 
备忘...备忘...

 

posted on 2009-06-15 12:20  太清  阅读(2230)  评论(0编辑  收藏  举报