Reputation: 103155
I am attempting to create a struts2 component using freemarker. I created an ftl
file with code like this:
<script type="text/javascript" src="${parameters.library?default('')}"></script>
Which is expecting a parameter named library
to be passed to the component. If the parameter is absent then it defaults to a blank String
.
On my JSP page, I am referring to the component like this:
<s:component template="mytemplate.ftl">
<s:param name="library" value="/scripts/mylibrary.js"/>
</s:component>
Unfortunately, the value for the library parameter is not being set. It is always a blank String
.
I am using the advice from this tutorial and it seems as if the s:param
tag should pass the parameter into the template and make it available. What am I missing here?
Does anyone have some experience building these components that could shed some light?
Thanks.
Upvotes: 1
Views: 4498
Reputation: 66
send the param with single quotes
<s:component template="mytemplate.ftl">
<s:param name="library" value="'/scripts/mylibrary.js'"/>
</s:component>
Upvotes: 5
Reputation: 103155
I eventually ran across some syntax in the docs that works. I have to refer to the parameter like this:
<script type="text/javascript" src="${parameters.get('library')?default('')}">
</script>
Upvotes: 0