0

Spring 是否从那里读取任何配置文件,知道要创建一些默认的开箱即用实现(HandlerMappingViewResolver)?

4

1 回答 1

0

是的,DispatcherServlet.propertiesorg.springframework.web.servletpacakge 中就是您要找的东西。

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());
    }
 }
于 2012-07-30T11:08:00.393 回答