Spring是否读取了任何配置文件,知道是否要创建一些默认的开箱即用实现(HandlerMapping
,ViewResolver
等)?
答案 0 :(得分:0)
是的,DispatcherServlet.properties
包中的org.springframework.web.servlet
就是你要找的东西。
DispatcherServlet源中的相关代码段:
/**
* Name of the class path resource (relative to the DispatcherServlet class)
* that defines DispatcherServlet's default strategy names.
*/
private static final String DEFAULT_STRATEGIES_PATH ="DispatcherServlet.properties";
....
static {
// Load default strategy implementations from properties file.
// This is currently strictly internal and not meant to be customized
// by application developers.
try {
ClassPathResource resource = new ClassPathResource(DEFAULT_STRATEGIES_PATH, DispatcherServlet.class);
defaultStrategies = PropertiesLoaderUtils.loadProperties(resource);
}
catch (IOException ex) {
throw new IllegalStateException("Could not load 'DispatcherServlet.properties': " + ex.getMessage());
}
}