Passing a parameter to the struts2 component
I am trying to create a struts2 component using freemarker. I created a file ftl
with code like this:
<script type="text/javascript" src="${parameters.library?default('')}"></script>
It is expected that a named parameter library
will be passed to the component. If the parameter is absent, then the default is a space String
.
In my JSP page, I access this component like this:
<s:component template="mytemplate.ftl">
<s:param name="library" value="/scripts/mylibrary.js"/>
</s:component>
Unfortunately, no value was specified for the library parameter. It's always empty String
.
I'm using the advice from the tutorial and it seems that the tag s:param
should pass this parameter to the template and make it available. What am I missing here?
Does anyone have any experience creating these components that might shed some light?
Thank.
source to share