FreemarkerConfiguration.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:private-freemarker 作者:
public static Template getTemplate(String name) {
    Template template = null;
    try {
        Version version = new Version("2.3.0");
        Configuration cfg = new Configuration(version);
        // 读取ftl模板
        cfg.setClassForTemplateLoading(FreemarkerConfiguration.class, "/ftl");
        cfg.setClassicCompatible(true);
        cfg.setDefaultEncoding("UTF-8");
        cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
        cfg.setObjectWrapper(new SaicObjectWrapper(cfg.getIncompatibleImprovements()));
        template = cfg.getTemplate(name);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return template;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号