对于static的理解
来源:互联网 发布:c语言单竖线 编辑:程序博客网 时间:2024/05/29 03:00
今天看SpringMVC中Dispatcher源代码发现了一个static关键词的用法,因为在java中会先去加载静态变量,静态代码块,再去加载非静态变量,普通代码块。所以dispatcher中有一段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());
}
// 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());
}
}
去加载默认的配置。这样就可以做到,在程序启动时先去加载默认的配置,然后调用onRefresh(ApplicationContext context)方法去调用相应的方法加载自己配置的组件覆盖默认配置。
阅读全文
2 0
- 对于static的理解
- 小K对于java中static的理解
- 对于static的学习心得
- 对于继承的理解
- 对于volatile的理解
- 对于分布式的理解
- 对于volatile的理解
- 对于const的理解
- 对于scull_read的理解
- 对于分页的理解
- 对于视图的理解
- 对于HBase的理解
- 对于STL的理解
- 对于覆盖的理解
- 对于context的理解
- 对于__syncthreads()的理解
- 对于终端的理解
- 对于ftok的理解
- netty+protobuf使用netty自带编解码器完成多种协议格式分发
- CS231n的主讲老师Andrej说,要从底层代码开始构建神经网络,而不是仅仅使用框架
- Codeforces Round #435 (Div. 2) C. Mahmoud and Ehab and the xor
- numpy.c/numpy.r
- Groovy基本使用(6):XML 处理
- 对于static的理解
- 视频前景目标提取(一)
- What is MCPTT
- 安卓sqlite之增删改查(一)
- validator配合ajx验证,并使用servlet处理json数据
- 音频学习资料整理
- 上传图片
- C++之对象的动态创建和释放
- ubuntu环境下安装anconda