Templates 将参数传递给struts2组件
我正在尝试使用freemarker创建struts2组件。我创建了一个ftl文件,代码如下: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
<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>