用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" />
<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" />
本文介绍了如何解决Struts2框架中使用OGNL表达式进行静态方法调用时遇到的问题。通过修改struts.properties文件中的struts.ognl.allowStaticMethodAccess配置项为true来启用静态方法调用。
176

被折叠的 条评论
为什么被折叠?



