2

tomcat7 のサーブレット 3.0 で Rythm テンプレート エンジンを使用しようとしています。テンプレートをディレクトリからエンジン
にレンダリングしたい。しかし、それはテンプレートを検出していません。WebContentRythm

サーブレットinit()メソッドでは、Rthym エンジンを次のように初期化しました。

public void init(ServletConfig config) throws ServletException {
        Map <String, Object> context = new HashMap <String, Object> ();
        //String filePath = new File("").getAbsolutePath();
        //filePath.concat("WebContent");
        context.put("home.template", "WebContent");
        Rythm.init(context);
    }

次に、メソッドを使用NewFile.htmlして次のようにレンダリングしようとしましたRythm.renderdoGet

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Map <String, Object> args = new HashMap <String, Object> ();
        args.put("a", "World");
        PrintWriter out = response.getWriter();
        out.println(Rythm.render("NewFile.html", args));
    }

しかし、ブラウザには「NewFile.html」だけが表示されています(NewFile.htmlのコンテンツではなく、文字列「NewFile.html」のみ)

4

2 に答える 2

2

私はRythmで同様の問題を抱えていました.私の場合、ファイル名の前にディレクトリを書くのに役立ちました:

Rythm.render("templates/" + templateFileName, parameters);

変数の設定もhome.templateうまくいきませんでした。

于 2014-10-21T19:54:46.323 に答える