-->

Freemarker - Include Multiple templates inside con

2020-05-06 10:42发布

问题:

How can i include more than one template in Freemarker configuration file using Smooks?

<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd">

<params>
  <param name="stream.filter.type">SAX</param>
  <param name="default.serialization.on">false</param>
</params>

<ftl:freemarker applyOnElement="Response">
  <ftl:template>template1.ftl</ftl:template>
  <ftl:template>template2.ftl</ftl:template>
</ftl:freemarker>

This doesnt seem to work. Throws an error at the second template line

回答1:

If you look at example you will see that each ftl:template tag should be inside ftl:freemarker tag. in your case:

<ftl:freemarker applyOnElement="Response">
  <ftl:template>template1.ftl</ftl:template>
</ftl:freemarker>
<ftl:freemarker applyOnElement="Response">
  <ftl:template>template2.ftl</ftl:template>
</ftl:freemarker>