public void test() throws Exception {
Configuration cfg = new Configuration();
cfg.setDirectoryForTemplateLoading(new File("" + "./src"));
cfg.setObjectWrapper(new DefaultObjectWrapper());
Map<String, Object> root = new HashMap<String, Object>();
root.put("user", "Koma");
Map<String, String> latest = new HashMap<String, String>();
root.put("latestProduct", latest);
latest.put("url", "1.htm");
latest.put("name", "product name");
Template temp = cfg.getTemplate("test.ftl");
Writer out = new OutputStreamWriter(System.out);
temp.process(root, out);
out.flush();
}
自分で作ったり提供したりするものは、まず自分自身で使ってみろろということです。自分じゃ使わないものなら人はいくらでも無責任にも無思考にもなれる。そういう投げやりな「サービス」やら「プロダクツ」なんて、だれだってイヤだ。自分が作り手と同時に利用者の立場になれば、ちゃんと使えるレベルのものを提供しようとします。
2011年12月23日金曜日
Hello Freemarker
test.java
...
登録:
コメント (Atom)