Web アプリケーションの HTML メール ユーティリティに Apache Velocity テンプレート エンジンを使用しています。
しかし、私が直面している主な問題はリソース パスです。私は自分のWebアプリケーション(Struts2 maven arch ..プロジェクト)にstruts2を使用しています。フォルダーテンプレートを作成し、その中にテンプレートであるemail.vmファイルを作成したので、テンプレートフォルダーをリソースに移動しました(戦争が作成されるときWEB-INF/classes フォルダーに移動します)
&私のユーティリティクラスでは、次のようにテンプレートを取得しようとしています:
VelocityEngine ve = new VelocityEngine();
ve.init();
VelocityContext context = new VelocityContext();
context.put("petList", list);
log.info("Context added");
/*
* get the Template
*/
Template t = ve.getTemplate("email.vm" );
log.info("Got Template");
/*
* now render the template into a Writer, here
* a StringWriter
*/
StringWriter writer = new StringWriter();
t.merge( context, writer );
だから私はエラー org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'template.vm' を取得しています
私はstackoverflowでこれに関するすべての関連する質問を調べ、解決策を適用しましたが、まだ運がありません。