I figured out one way to achieve this: with Struts alone you cannot read properties name-value pair, but via Spring and action class you can.
With Spring PropertySourcesPlaceholderConfigurer
we can read value from .properties
files with ${name.in.prop.file}
, so we can add parameters when constructing Action
bean, like this:
<bean id="someAction" class="path.to.someAction" scope="session">
<property name="manager1" ref="manager1" />
<property name="manager2" ref="manager2" />
<property name="myWebsiteURL" value="${my.website.url}" />
</bean>
And, define this myWebsiteURL
of type java.lang.String
in Action class, along with its getter/setter, so Spring can inject the value you need in myWebsiteURL
upon Action class's creation.
At last, invoke this value like this in struts.xml
with ${myWebsiteURL}
(the reason why it's working is still to be investigated, but it's working). For example, you can write this:
<action name="goToSomeSite" method="goToSomeSite" class="myAction">
<result name="success" type="redirect">${myWebsiteURL}</result>
....
</action>
The only thing that I don't understand, is how ${myWebsiteURL}
is get evaluated. With Spring? Struts? JSTL? (I don't include JSTL libs in my project)