There's a similar thread that was never answered properly.
I'm trying to call a Struts 2 Action method from a JSP using <s:property>
and this method takes a param. The value I'd like to pass is in a variable.
<s:set var="myvar" value="..." />
Value of variable: <c:out value="${myvar}" /> <!-- This works OK -->
<!-- Now, need to call a method called getActionCategory(str) which takes this var value -->
Method call: <s:property value="%{getActionCategory(myvar)}"/>
This doesn't work:
myvar
comes in as NULL.
Also, inserting value="%{getActionCategory(${myvar})}
into the parentheses doesn't work: According to TLD or attribute directive in tag file, attribute [value] does not accept any expressions
This simplified reference with no get
and a param also brings in a NULL for the param value: <s:property value="actionCategory(myvar)" />
(contrary to this post)
The only thing that works is using literal constants, like value="%{getActionCategory('abc')}"
, which I don't want.
I figured it out:
<s:property value="%{getActionCategory(#myvar)}"/>