1

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でこれに関するすべての関連する質問を調べ、解決策を適用しましたが、まだ運がありません。

4

1 に答える 1

2

http://velocity.apache.org/engine/releases/velocity-1.5/developer-guide.html#resourceloadershttp://tech--help.blogspot.com/2010/02/solved-apache-を読んでください。速度-how-to-load.html . そして、次回はグーグルを使用してください。

于 2012-10-17T08:30:56.867 に答える