Struts 2 cannot resolve java action method in # tag

Viewed 28

There's something I'm been missing in how Struts resolve ftl tag, I have an action with some methods that I'm trying to call from my ftl.

The signature:

<@s.property value="%{someJavaMethod(someVariable)}>

is working fine, but the directive

<#include someJavaMethod(someOtherVariable)>

is giving me this:

----: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> someJavaMethod

and I cant figure out why, since, based on my limited knowledge of struts the signature # has access to the context Map where action properties and methods are stored.

NB: I checked that the problem is not in the someJavaMethod since debugging the code it doesn't even enter into.

1 Answers

You should reference the action to call its method in Freemarker. It is supported by the Struts 2 framework.

<#include action.someJavaMethod(someOtherVariable)>
Related