Static method access has been disabled by default since around 2008-2009 with Struts 2.1+.
Nutshell: you must explicitly enable static method access.
This change was detailed in both the release notes and the migration guide.
Question
We had following working ftl which was deployed on struts 2.0.11
FTL::
[#list allPaymentMethods?sort as item]
options = options + "<option name='${item?string}' value='${item?string}' [#if paymentMethods.contains(item)]selected='selected'[/#if]>${item?string}</option>";
[/#list]
The corresponding action class has following method which returns a non null list.
public static List<String> getAllPaymentMethods()
This implementation was working with struts 2.0.11 and freemarker 2.3.10.
It starts giving Expression undefined error
while parsing ftl after we upgraded to struts 2.3.16 and freemarker 2.3.19.
The error goes away if we make the static method to an instance method.
public List<String> getAllPaymentMethods()
We were expecting struts/freemarker to be backward compatible.
It seems struts-2.3.16/freemarker-2.3.19 does not support static getter methods on action class. Has anyone observed similar issue? Or the way we have been using static getters is not recommended?
While migrating, it is very difficult to go through all ftls/Java code to identify and convert such static getter methods to instance methods.
Is there any other alternatives we can use to migrate such code/ftl?
Solution
Static method access has been disabled by default since around 2008-2009 with Struts 2.1+.
Nutshell: you must explicitly enable static method access.
This change was detailed in both the release notes and the migration guide.