将参数传递给struts2组件

Vin*_*nie 1 templates components freemarker struts2

我正在尝试使用freemarker创建一个struts2组件.我ftl用这样的代码创建了一个文件:

<script type="text/javascript" src="${parameters.library?default('')}"></script>
Run Code Online (Sandbox Code Playgroud)

期望一个名为library传递给组件的参数.如果参数不存在则默认为空白String.

在我的JSP页面上,我指的是这样的组件:

<s:component template="mytemplate.ftl">
    <s:param name="library" value="/scripts/mylibrary.js"/>
</s:component>
Run Code Online (Sandbox Code Playgroud)

不幸的是,没有设置library参数的值.它总是一片空白String.

我正在使用本教程中的建议,似乎s:param标记应该将参数传递给模板并使其可用.我在这里错过了什么?

有没有人有一些建立这些组件的经验可以解决一些问题?

谢谢.

小智 5

用单引号发送参数

<s:component template="mytemplate.ftl">
    <s:param name="library" value="'/scripts/mylibrary.js'"/>
</s:component>
Run Code Online (Sandbox Code Playgroud)