![](https://csdnimg.cn/release/download_crawler_static/4795301/bg4.jpg)
}
this .pathPrefixes
=
parse(packages);
} finally {
ActionContext.setContext(
null
);
}
}
顺着流程我们看 Disptcher 的 init 方法。 init 方法里就是初始读取一些配置文件等,先 看
init_DefaultProperties ,主要是读取 properties 配置文件。
private void init_DefaultProperties() {
configurationManager .addConfigurationProvider( new DefaultPropertiesProvider
());
}
打开 DefaultPropertiesProvider
public void register(ContainerBuilder
builder,
LocatableProperties props)
throws ConfigurationException {
Settings defaultSettings
=
null
;
try {
defaultSettings
=
new PropertiesSettings("org/apache/struts2/default");
} catch (Exception e) {
throw new ConfigurationException("Could not find or error
in
org/apach
e/struts2/default.properties", e);
}
loadSettings(props, defaultSettings);
}
//PropertiesSettings
// 读取 org/apache/struts2/default.properties 的配置信息 , 如果项目中需要覆盖 , 可以在 c
lasspath 里的 struts.properties 里覆写
public PropertiesSettings(String nam e) {
URL settingsUrl
=
ClassLoaderUtils.getResource(nam e
+
".properties", getCl
ass());
if (settingsUrl
==
null
) {
LOG.debug(name
+
".properties missing");
settings
=
new LocatableProperties();
return ;
}