Configuration
createConfiguration()
throwsConfiguration config =
IOException, TemplateException {
newConfigurationProperties props =
();
newProperties();
// 可以直接通过configLocation加载FreeMarker的基本配置 if(
this.
configLocation!=
null) {
if(logger.
isInfoEnabledlogger.
()) {
info(
"Loading FreeMarker configuration from "+
this.
configLocationPropertiesLoaderUtils.
}
);
fillProperties(props,
this.
configLocation}
);
// Merge local properties if specified. if(
this.
freemarkerSettings!=
nullprops.
) {
putAll(
this.
freemarkerSettings}
);
//只会保存已有的内部属性,比如time_format。更多的可查看Configuration#setSetting()方法 if(!props.
isEmptyconfig.
()) {
setSettings}
(props);
if(!CollectionUtils.
isEmpty(
this.
freemarkerVariablesconfig.
)) {
setAllSharedVariables(
new SimpleHash(
this.
freemarkerVariables, config.
getObjectWrapper}
()));
if(
this.
defaultEncoding!=
nullconfig.
) {
setDefaultEncoding(
this.
defaultEncodingList
}
);
newLinkedList
.
templateLoaders);
// Register template loaders that are supposed to kick in early. if(
this.
preTemplateLoaders!=
nulltemplateLoaders.
) {
addAll(
this.
preTemplateLoaders}
);
// Register default template loaders. if(
this.
templateLoaderPaths!=
null) {
for(String path :
this.
templateLoaderPaths) {
//加载templateLoaderPath指定的资源,创建相应的加载器templateLoaders.
add(
getTemplateLoaderForPath}
}
(path));
//将templateLoaders放入内部属性templateLoaders集合中 postProcessTemplateLoaders(templateLoaders);
// Register template loaders that are supposed to kick in late. if(
this.
postTemplateLoaders!=
nulltemplateLoaders.
) {
addAll(
this.
postTemplateLoaders}
);
//选取一个templateLoader用于加载真实的view视图资源TemplateLoader loader =
getAggregateTemplateLoader(templateLoaders);
if(loader !=
nullconfig.
) {
setTemplateLoader}
(loader);
//默认为空方法 postProcessConfiguration(config);
return}
config;
来源: http://www.cnblogs.com/question-sky/p/7235634.html