I have a Struts 2 JSP page with the following snippet:
which correctly prints out the value of
I think you are missing target object, ex
<s:property value="%{myTarget.myMethod(myVariable)}" />
More: How to pass parameter to method call in Struts 2 OGNL
<s:property value="%{myMethod(myVariable)}" />
is a correct syntax, but to get the value of the method that have a signature
public String myMethod(String value){
return value;
}
required the getter for myVariable
public String getMyVariable() {
return myVariable;
}
if you set the value to myVariable
like
private String myVariable = "myValue";
then it should be printed in JSP. If the argument is other type it will be converted to String
and the method will call.