I have a Struts 2 JSP page with the following snippet:
<s:property value="%{myVariable}" />
which correctly prints out the value of myVariable
.
Now, I want to pass myVariable
to a method in my action that computes a result based on the value of myVariable
. I tried the following:
<s:property value="%{myMethod(myVariable)}" />
The first line in myMethod
prints out a debug statement. With the above snippet, this debug statement was not printed.
I then tried this:
<s:property value="%{myMethod(#myVariable)}" />
My debug statement printed, but the value of myVariable
was passed as null even though it has a value when it is printed via <s:property value="%{myVariable}" />
What is the correct syntax for passing a page variable to a Struts 2 method?