import com.jfinal.kit.Kv; import com.jfinal.plugin.activerecord.Record; import com.jfinal.template.Engine; public class Main { public static void main(String[] args){ Engine engine = Engine.use(); engine.setDevMode(true); String s = engine.getTemplate("C:\\Users\\admin\\Desktop\\a\\index.html").renderToString(Kv.by("r",new Record().set("k","v"))); System.out.println(s); } }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> #(r.k) </body> </html>
Exception in thread "main" com.jfinal.template.TemplateException: public field not found: "r.k" and public getter method not found: "r.getK()"
Template: "/C:\Users\admin\Desktop\a\index.html". Line: 8
at com.jfinal.template.expr.ast.Field.eval(Field.java:88)
at com.jfinal.template.stat.ast.Output.exec(Output.java:49)
at com.jfinal.template.stat.ast.StatList.exec(StatList.java:68)
at com.jfinal.template.Template.render(Template.java:74)
at com.jfinal.template.Template.renderToString(Template.java:91)
at com.quick.Main.main(Main.java:12)