Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates 将参数传递给struts2组件_Templates_Struts2_Components_Freemarker - Fatal编程技术网

Templates 将参数传递给struts2组件

Templates 将参数传递给struts2组件,templates,struts2,components,freemarker,Templates,Struts2,Components,Freemarker,我正在尝试使用freemarker创建struts2组件。我创建了一个ftl文件,代码如下: <script type="text/javascript" src="${parameters.library?default('')}"></script> <s:component template="mytemplate.ftl"> <s:param name="library" value="/scripts/mylibrary.js"/&g

我正在尝试使用freemarker创建struts2组件。我创建了一个ftl文件,代码如下:

<script type="text/javascript" src="${parameters.library?default('')}"></script>
<s:component template="mytemplate.ftl">
    <s:param name="library" value="/scripts/mylibrary.js"/>
</s:component>
<script type="text/javascript" src="${parameters.get('library')?default('')}">
</script>
很遗憾,没有设置库参数的值。它总是一个空白字符串

我使用的是来自本文的建议,似乎s:param标记应该将参数传递到模板中并使其可用。我错过了什么

有没有人有过构建这些组件的经验,可以提供一些信息


谢谢。

我最终在文档中找到了一些有效的语法。我必须参考如下参数:

<script type="text/javascript" src="${parameters.library?default('')}"></script>
<s:component template="mytemplate.ftl">
    <s:param name="library" value="/scripts/mylibrary.js"/>
</s:component>
<script type="text/javascript" src="${parameters.get('library')?default('')}">
</script>

我最终在文档中遇到了一些有效的语法。我必须参考如下参数:

<script type="text/javascript" src="${parameters.library?default('')}"></script>
<s:component template="mytemplate.ftl">
    <s:param name="library" value="/scripts/mylibrary.js"/>
</s:component>
<script type="text/javascript" src="${parameters.get('library')?default('')}">
</script>

用单引号发送参数

<s:component template="mytemplate.ftl">
    <s:param name="library" value="'/scripts/mylibrary.js'"/>
</s:component>

用单引号发送参数

<s:component template="mytemplate.ftl">
    <s:param name="library" value="'/scripts/mylibrary.js'"/>
</s:component>