STRUTS2 标签调用静态方法

struts2 ognl 调用静态方法

用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" />
原文地址:https://www.cnblogs.com/weipeng/p/2542155.html