FreeMarker过时的方法 new Configuration()

FreeMarker过时的方法 new Configuration()

通过这个方法获得一个Configuration实例已经过时


经过查看源码发现,通过此方式获得一个Configuration实例,他需要一个版本信息

就是说现在你要获得一个 Configuration实例需要一个版本实例,目前我的版本是2.3.23

// Create your Configuration instance, and specify if up to what FreeMarker 

// version (here 2.3.23) do you want to apply the fixes that are not 100% 

// backward-compatible. See the Configuration JavaDoc for details. Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);

Configuration.VERSION_2_3_22 是一个静态字段


public static final Version VERSION_2_3_23
那么从现在开始(以前或许不需要这样),就需要使用以下代码来实现了



Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
		
// 初始化一些配置
cfg.setDirectoryForTemplateLoading(new File("d:\\freemarker"));
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
		


[caption id="attachment_1017" align="alignnone" width="347"]Freemarker 过时的方法 Freemarker 过时的方法[/caption]

爆款云服务器s6 2核4G 低至0.46/天,具体规则查看活动详情Blog Img