STRUTS2 标签调用静态方法

用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"   />

猜你喜欢

转载自free0007.iteye.com/blog/1774960