OGNL表达式提供了一种访问静态成员(包括调用静态方法、访问静态成员变量)的方法,但Struts2默认关闭了访问静态方法,只允许通过OGNL表达式访问静态Field。
只需在struts.xml里添加如下片段:
<!--打开静态方法调用的限制-->
<constant name="struts.ognl.allowStaticMethodAccess" value="true"/>
同样可以查看default.properties
<!--打开静态方法调用的限制-->
<constant name="struts.ognl.allowStaticMethodAccess" value="true"/>