1
XMLファイルを解析してVelocityテンプレートのデータを使用できるようにXmlToolを使用しようとしています。VelocityツールXmlTool
しかし、そのドキュメントはすべて非常に貧しく、必要な情報を実際に提供していません。
ドキュメントはである:https://velocity.apache.org/tools/devel/apidocs/org/apache/velocity/tools/generic/XmlTool.html
そして、私が試してみました:
VelocityContext context = new VelocityContext(page);
EasyFactoryConfiguration config = new EasyFactoryConfiguration();
config.toolbox("application")
.tool("org.apache.velocity.tools.generic.XmlTool")
.property("safeMode", false)
.property("key", "foo")
.property("file", xmlFilePath);
ToolboxFactory factory = config.createFactory();
template = Velocity.getTemplate(page.get("template-file"));
template.merge(context, write);
return write.toString();
しかし、これは動作しません。 データを実際にテンプレートにする方法を教えてください。私はたくさんのステップがありませんが、必要な情報は見つけられません。
エラーは何ですか?あなたのテンプレートはどのように見えますか? –