Using ognl to access static methods in Struts2

1. Modify the struts configuration file and set struts.ognl.allowStaticMethodAccess to true
<constant name="struts.ognl.allowStaticMethodAccess" value="true"></constant>
If not set, it will cause WARN OgnlValueStack:45 - Could not find method warning
2. If the above error does not appear on the console, check the log4j-related configuration and whether the ognl-related log is set to the error level, such as:
log4j.logger.com.opensymphony.xwork2.util.OgnlUtil=error
log4j.logger .com.opensymphony.xwork2.ognl.OgnlValueStack=error
If so, remove it and keep the default level, then you can see the related errors in the
console Use static method in
<s:date name="@com.app.util.DateUtils@getDateByInt(sendDate)" format="yyyy-MM-dd HH:mm:ss"/>

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327053551&siteId=291194637