Search code examples
struts2struts

How to pass a variable to s:text?


First things first, I'm not a seasoned Struts user. Here is my struts code:

<s:set var="foo" value="BAR">

<s:text name="key.for.foo">
    <s:param><s:property value="foo" /></s:param>
</s:text>

Here is the properties file containing the key.for.foo text value:

key.for.foo=blah blah {0}

I expect the text below:

blah blah BAR

but I get

blah blah

What am I missing ?


Solution

  • You can try the below code

    <s:text name="key.for.foo"><s:param value="#foo"/></s:text>